Course Code: 23ADS1102 Course Name: C.
Programming Lab
Name of Students: Dhanshree Gaur Semester : 1st Semester / Section M
Roll No: M-05 Enroll No: 24070403
Problem Definition:
Write a program to perform arithmetic operations on values entered by the user.
Source Code in C:
#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.