Thursday, 15 December 2011

if - break


#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int a,bil;
char lagi;
cout<<"\n\n                PROGRAM MENAMPILKAN BILANGAN GANJIL [1-100] "<<endl;
cout<<"                      MENGGUNAKAN FOR, IF DAN BREAK"<<endl;
cout<<"           ++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
awal:
cout<<"\n\n              Masukkan batas tampil (Harus Bilangan Ganjil)= ";
cin>>a;
cout<<"================================================================================"<<endl;
for(bil=1; bil<=100;bil+=2)
{
cout<<" ["<<bil<<"]";
if(bil==a)
break;
}
cout<<"\n================================================================================"<<endl;
cout<<"\n\n     Apakah anda ingin menampilkan lagi dengan batas yang lain..???"<<endl;
cout<<"     Jawab  [Y/T] = ";
cin>>lagi;
if (lagi=='y'|| lagi=='Y')
{
cout<<"\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
goto awal;
}
else
cout<<"\n\n\n\n\n\n\n                                 TERIMA KASIH TELAH MENGGUNAKAN PROGRAM SAYA.."<<endl;
cout<<"                                 OLEH  : JAYARI (10 54 0040)"<<endl;
cout<<"\n\n  << PRESS ANYKEY TO EXIT...!!!>>";

getch();
}

No comments:

Post a Comment