#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,x;
printf("\Enter three number:-");
x=scanf("%d %d %d",&a,&b,&c);
if(x==3)
{
printf("\n Addition: %d",a+b+c);
printf("\n Multiplication: %d",a*b*c);
}
}
The above program reads three integer values from the user and assigns them to the variables a
, b
, and c
using scanf()
.
It then uses an if
statement with curly braces to check if three values were successfully entered. If scanf()
returns 3, which indicates that three values were entered correctly, then the statements inside the curly braces will be executed.
The program then calculates the sum and multiplication of the three numbers using the +
and *
operators, respectively, and displays the results using printf()
.
Note that the curly braces are not strictly necessary in this program since there is only one statement inside the if
block. However, it is good practice to use curly braces even for a single statement to avoid potential errors and improve code readability.
Thanks