Sunday, August 22, 2010

Program C++ Mencari Nilai Rata-Rata Dengan For :

#include
02#include
03
04void main()
05{
06    float n, total, rata2;
07    total = 0;
08    for(int i=0; i<10; i++)
09    {
10        cout<<"Masukkan nilai ke "<<(i+1)<<" : ";
11        cin>>n;
12        total = total + n;
13    }
14    rata2 = total / 10;
15    cout<<"Total = "<<
16    cout<<"Rata2 = "<<
17    getch();
18}

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Laundry Detergent Coupons