Arithmetic Operations in C

An operator is a symbol that operates on a value or a method. (Symbols such as +,-,*,/,%)

An arithmetic operator performs mathematical operations such as addition, subtraction, multiplication, division, modulus on numeric values.

Below coding is the program for Arithmetic Operations in C using switch case conditions.

 

//Arithmetic Operation
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z,ch;
clrscr();
printf("\n1 - Addition\n2 - Subtraction\n3 - Multiplication\n4 - Division\nEnter ur choice: ");
scanf("%d",&ch);
printf("Enter the two Numbers:\n");
scanf("%d%d",&x,&y);
switch(ch)
{
case 1: z=x+y;
break;
case 2: z=x-y;
break;
case 3: z=x*y;
break;
case 4: z=x/y;
break;
default: printf("\n\n\nUr Choice s Wrong");
}
printf("The Result is %d",z);
getch();
}

 

 

Leave a Reply