/* Program to find the sum and product of two numbers */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum=0,product=0;
printf("\n Enter the value of a and b );
scanf("%d%d",&a,&b);
sum=a+b;
product=a*b;
printf("\n The sum of a and b is = %d",sum);
printf("\n The product of a and b is = %d",product);
getch( );
}
Output
Enter the value of two numbers 60
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum=0,product=0;
printf("\n Enter the value of a and b );
scanf("%d%d",&a,&b);
sum=a+b;
product=a*b;
printf("\n The sum of a and b is = %d",sum);
printf("\n The product of a and b is = %d",product);
getch( );
}
Output
Enter the value of two numbers 60
3
The sum of a and b is 63The product of a and b is 180
In this program we are adding two numbers and multiplying two numbers with the help of programming language.
First we are declaring the two variable i.e., a and b and the variable sum and product with zero.
Then we are entering the message to enter two numbers. Then the condition of sum and product are written so that it can execute the program.
Lastly the answers of the above mentioned question are printed.
Finally it will look like as shown below-
And the outputs are as follows:
No comments:
Post a Comment