A program to read the value of two variables and compute sum, difference and product
In this post, i am going to write the C source code examples to the read the two variables provided by user and compute their sum difference and product.
/*A program to read the value of two variables and compute sum, difference and product
programmed by:
Name: Jitendra Kumar Yadav
Roll no: 16
Date: 30 december 2010 */
#include <stdio.h>
#include <conio.h>
void main()
{
float a,b,s,d,p;
printf(“Enter the first variable:”);
scanf(“%f”,&a);
printf(“Enter the second variable:”);
scanf(“%f”,&b);
s=a+b;
d=a-b;
p=a*b;
printf(“The sum of %f+%f=%f”,a,b,s);
printf(“\nThe diff of %f-%f=%f”,a,b,d);
printf(“\nThe product of %f*%f=%f”,a,b,p);
getch();
}
Copy the above C source code and copy in your compiler text editor and then compile it and then run.
Output example
Enter the first variable:3.5
Enter the second variable:1.5
The sum of 3.500000+1.500000=5.000000
the diff of 3.500000-1.500000=2.000000
The product of 3.500000*1.500000=5.250000








