Thursday, May 30, 2019

C Programming : program to find sum and product of two numbers;

/* 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  

 3

The sum of a and b is 63
The 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

Function

FUNCTION C enables programmer to break up a program into segments commonly known as functions, each of which can be written more or...