Friday 21 October 2011

How to Determine the average C++

How to Determine the average. it's easy to make this program. The first step is to put 5 pieces of numbers. Then to find the numbers, five numbers were summed up, and to find the average, for the amount of numbers with 5.
Very easy is not.

Here it is its syntax ..

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

void main()
{
 int bil1,bil2,bil3,bil4,bil5;
 int jumlah;
 float rata_rata;

 cout<<"Masukkan Bilangan 1 : "; cin>>bil1;
 cout<<"Masukkan Bilangan 2 : "; cin>>bil2;
 cout<<"Masukkan Bilangan 3 : "; cin>>bil3;
 cout<<"Masukkan Bilangan 4 : "; cin>>bil4;
 cout<<"Masukkan Bilangan 5 : "; cin>>bil5;

//Menghitung Jumlah Bilangan
 jumlah = bil1 + bil2 + bil3 + bil4 + bil5;
 //Output Jumlah Bilangan
 cout<<endl;
 cout<<"Jumlah Bilangan = "<<jumlah<<endl;
 //Rata-rata Bilangan
 rata_rata = jumlah / 5;
 cout<<endl;
 cout<<"Rata-rata Bilangan = "<<rata_rata<<endl;
}



its so easy thanks for reading

No comments:

Post a Comment