# C++ Program to perform all arithmetic calculation using switch case

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
float a,b,res;
int ch,q;
cout<<“Arithmetic Operatios”;
cout<<“nn1.Additionn2.Subtractionn3.Multiplicationn4.Divisionn5.Mode”;
cout<<“n  Enter your choice:”;
cin>>ch;

switch(ch)
{
case 1:
{
cout<<“nnEnter two variables:”;
cin>>a>>b;
res=a+b;
cout<<“n  Result=”<<res;
}
break;

case 2:
{
cout<<“nnEnter two variables:”;
cin>>a>>b;
res=a-b;
cout<<“n  Result=”<<res;
}
break;

case 3:
{
cout<<“nnEnter two variables:”;
cin>>a>>b;
res=a*b;
cout<<“n  Result=”<<res;
}
break;

case 4:
{
cout<<“nnEnter two variables:”;
cin>>a>>b;
if(a>=b)
{
res=a/b;
cout<<“n  Result=”<<res;
}
else
cout<<“nnt1st varable should be greater than 2nd.!!!”;
}
break;

case 5:
{
cout<<“nnEnter two variables:”;
cin>>a>>b;
if(a>=b)
{
q=a/b;
res=a-(b*q);
cout<<“n  Result=”<<res;
}
else
cout<<“nnt1st variable should be greater than 2nd..!!!”;
}
break;
}

getch();
}

## 4 thoughts on “C++ Program to perform all arithmetic calculation using switch case”

1. L Benjmin

Please post a program to find sum of two comparable matrix.

2. Mayuri

How to get this series ?
1
123
1234
12345

1. seemi

in simple c language prog to make a looped triangle

#include
main()
{
int i , j ;
for (i = 1 ; i < = 5 ; i ++)
{
for ( j = 1 ; j < = i ; j ++)
{
printf ("%d " , j);
}
printf ("\n");
}
}

2. Mohammead ashik

Poi pani nokkada no sillly doubts using nested loop we could print in that order. Using nested loop will be the most appropriate way to solve such a problem