by CodeChum Admin
Now that we're done with integers, we're moving on to decimals!
Instructions:
Input
1. First decimal number
2. Second decimal number
3. Third decimal number
Output
The first three lines will contain message prompts to input the three decimal numbers.
The last line contains the result in two decimal places.
Enter·the·first·number:·1.53
Enter·the·second·number:·2.25
Enter·the·third·number:·1.23
Result·=·2.80
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
float number1,number2,number3,product,quotient;
printf("Enter the first number: ");
scanf("%f",&number1);
printf("Enter the second number: ");
scanf("%f",&number2);
printf("Enter the third number: ");
scanf("%f",&number3);
product=number1*number2;
quotient=product/number3;
printf("Result = %.2f\n",quotient);
getchar();
getchar();
return 0;
}
Comments
Leave a comment