C Programming Practical 2
C Programming Practical 2
Programming Lab
Problem Definition:
#include <stdio.h>
int main() {
float num1, num2, sum, diff, product, quotient;
printf("Enter the value of num1 : ");
scanf("%f", &num1);
printf("Enter the value of num2 : ");
scanf("%f", &num2);
{
sum = num1 + num2;
diff = num1 - num2;
product = num1 * num2;
quotient = num1 / num2;
}
printf("Sum of the numbers : %f\n", sum);
printf("Difference of the numbers : %f\n", diff);
printf("Product of the numbers : %f\n", product);
printf("Quotient of the numbers : %f\n", quotient);
return 0;
}
Output:
Conclusion:
I nthispracticalwestudiedhowtoperformarithmeticoperationonthevaluesenteredbythe
user,usingprintfandscanffunctions.Here,%fwasusedastheformatspecifiertospecify
the float value of the variables involved because it not necessary that all the results are
always integers with no decimals.