Write a C program that reads three integers a, b and c, and displays on the screen the result of the expression $$\frac{ab}{c}$$ if c is not null. Your program displays the message 'Wrong value of c' if c null.
Execution example:
Enter three numbers A, B and C: 3 5 10
$$\frac{a*b}{c}= 3 * 5/10 = 1.5$$
Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
int main()
{
int a, b, c;
printf("Enter 3 integers: ");
scanf("%d %d %d",&a, &b, &c);
if(c==0)
printf("Wrong value of c\n");
else
printf("a * b / c = %d * %d / %d = %.1lf\n", a, b,c, 1.0*a*b/c);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Alexandrine multiplication