C program to perform all arithmetic operations - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Saturday, June 15, 2019

C program to perform all arithmetic operations

In this tutorial we will perform all arithmetic operations by a program which are as addition, subtraction, multiplication, devide and reminder.

Solution

  • In this program we will use two values for performing the all arithmetic operations so we will take two variables for both values and five variables for arithmetic operations values.
  • We declared these variables in int data type.
  • Then we will enter the two numbers.
  • We use some logic for performing arithmetic operations as   
  1. sum=a+b
  2. sub=a-b
  3. mul=a*b
  4. div=a/b
  5. rem=a%b
  • When we use these statement the value of these operations will be store in own variable.
  • Then we will print the value of all arithmetic operations.


C program code


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
int b;
int sum,sub,mul,div,rem;
clrscr();

printf("\n Enter the value of a=");
scanf("%d",&a);

printf("\n Enter the value of b=");
scanf("%d",&b);

sum=a+b;
printf("\n The value of addition is=");
printf("%d",sum);

sub=a-b;
printf("\n The value of subtraction is=");
printf("%d",sub);

mul=a*b;
printf("\n The value of multiply is=");
printf("%d",mul);

div=a/b;
printf("\n The value of divison is=");
printf("%d",div);

rem=a%b;
printf("\n The value of reminder is=");
printf("%d",rem);
getch();
}


Output 1:



Output 2:




Arithmetic operations mean addition, subtraction, multiplication, devide and reminder. So we use these operations in this program.we will use two values for performing the all arithmetic operations so we will take two variables for both values and five variables for arithmetic operations values.

No comments:

Post a Comment