Tuesday, 17 April 2012

examples of repetition program

Program sederhana penjumlahan dan pengurangan diulang kembali,

#include <iostream.h>
#include <conio.h>
int main()
{
int a,b,x;
char n;
eroel:
cout<<"masikkan nilai a = ";
cin>>a;
cout<<"masukkan nilai b = ";
cin>>b;
x=a+b;
cout<<"hasil penjumlahan = "<<x<<endl;
x=a-b;
cout<<"hasil pengurangan = "<<x<<endl;
x=a*b;
cout<<"hasil perkalian = "<<x<<endl;
x=a/b;
cout<<"hasil pembagian = "<<x<<endl;
cout<<"ulangi program [y | n] ";
cin >>n;
if(n =='y' || n=='Y')
goto eroel;
else
cout<<"thanks";
system("pause");
return 0;
}

0 comments:

Post a Comment

.

.

.

.
Design by BlogSpotDesign | Ngetik Dot Com