Music ku

Tuesday, March 29, 2011

Exercises no 8

Write of program that needs 4 prices using while loop
and calculate the sum of the thing a program must
use function while for calculate the average of the
prices.

#include <iostream.h>
main ()
{
int k;
float P,total,average;
K=1
while (k<=4)
{
cout<<"Enter price"<<K<<"=j;
cin>>P;
k++; total=total+P;
}
average=total/4;
cout<<"your total is"<<total<<"and average is"average;
return 0;
}

No comments:

Post a Comment