Rabu, 17 April 2013

Program Menghitung Rata-rata

#include <iostream.h>
#include <conio.h>

main (void)
{
int a,b,c,d;
a=1;
b=0;
cout<<"masukkan n = ";
cin>>c;
cout<<"bilangan yang di cari rata rata adalah ="<<endl;
while (a<=c)
{
b=b+a;
cout<<a<<" ";
a++;
}
d=b/c;
cout<<endl<<endl<<"rata rata= "<<d;
getch();
}
separador

0 komentar:

Posting Komentar

Followers