Aoami
I am a FH squatter
- Joined
- Dec 22, 2003
- Messages
- 11,223
First time i've ever used C++, i'm in a lecture at uni atm. I've got to write a program to 'compute the sum, product and average of 5 numbers read in from the keyboard'
heres what i've got
#include<stdio.h>
void main()
{
float Num1, Num2, Num3, Num4, Num5;
float Sum, Product, Average;
printf("Please type in five numbers: ");
//scanf function allows the user to enter 5 numbers and store them as Num1, Num2 etc
scanf("%f%f%f%f%f", &Num1, &Num2, &Num3, &Num4, &Num5);
Sum = Num1+Num2+Num3+Num4+Num5;
Product = Num1*Num2*Num3*Num4*Num5;
Average = Sum/5;
printf("The results are: ");
printf("Sum=...... %f", Sum);
printf("Product=...... %f", Product);
printf("Average=...... %f", Average);
}
why doesn't it work :|
heres what i've got
#include<stdio.h>
void main()
{
float Num1, Num2, Num3, Num4, Num5;
float Sum, Product, Average;
printf("Please type in five numbers: ");
//scanf function allows the user to enter 5 numbers and store them as Num1, Num2 etc
scanf("%f%f%f%f%f", &Num1, &Num2, &Num3, &Num4, &Num5);
Sum = Num1+Num2+Num3+Num4+Num5;
Product = Num1*Num2*Num3*Num4*Num5;
Average = Sum/5;
printf("The results are: ");
printf("Sum=...... %f", Sum);
printf("Product=...... %f", Product);
printf("Average=...... %f", Average);
}
why doesn't it work :|
