C Program to Perform all Arithmetic Operations

 

C Program to Perform all Arithmetic Operations





// C Program to Perform all Arithmetic Operations
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum,sub,mult,division,rem;
clrscr();
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
sum=a+b;
printf("The addition of two numbers is:%d\n",sum);
sub=a-b;
printf("The subtraction of two numbers is:%d\n",sub);
mult=a*b;
printf("The multiplication of two numbers is:%d\n",mult);
division=a/b;
printf("The division of two numbers is:%d\n",division);
rem=a%b;
printf("The remainder of division is:%d\n",rem);
printf("End of program");
}


Enter two numbers:

100 20

The addition of two numbers is:120

The subtraction of two numbers is:80

The multiplication of two numbers is:2000

The division of two numbers is:5

The remainder of division is:0

End of program



// C program to perform arithmetic operations

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
//clrscr();
printf("\t\t\t***INPUT***\n");
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
printf("\t\t\t***OUTPUT***\n");
printf("The addition of two numbers is:%d\n",a+b);
printf("The subtraction of two numbers is:%d\n",a-b);
printf("The multiplication of two numbers is:%d\n",a*b);
printf("The division of two numbers is:%d\n",a/b);
printf("The remainder of division is:%d\n",a%b);
printf("End of program");
}


***INPUT***

Enter two numbers:

20 20

***OUTPUT***

The addition of two numbers is:40

The subtraction of two numbers is:0

The multiplication of two numbers is:400

The division of two numbers is:1

The remainder of division is:0

End of program


In above program addition, subtraction, multiplication, division and remainder operations are performed. The processing statements are directly used in printf() function. No any other variable is declared to store the result.

टिप्पणी पोस्ट करा

0 टिप्पण्या