Sunday, 15 November 2015

C++ Program For Arithmetic Operations Using Switch Case

Problem:- C++ Program For Arithmetic Operations Using Switch Case or Write A C++ To Perform All Arithmetic Operations Using Switch Case or C++ Program to Make a Simple Calculator Using Switch Case Statement or c++ program to perform arithmetic operations using functions or simple calculator program in c++ or calculator program in c++ using class or c++ program for arithmetic operations using class or scientific calculator program in c++ using switch case or c++ program to perform arithmetic operations using objects and classes or calculator program in c++ using functions or simple calculator program in c++ or c program to perform arithmetic operations using functions

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Logic:- First we are printing the message on screen with 4 options then we are asking for choosing any one of option and after that take two Number form user and pass both number in Switch Case, first write all the cases(for Addition, Subtraction, Multiplication, Division and Mode) then write a code according to statement and execute the operation according to user choice. If you want to see more like this one see C Program To Find The Day Using Switch Case.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.

Solution:-

#include<iostream>
using namespace std;
int main()
{
//By-Ghanendra Yadav
float a,b,rem;
int ch,q;

cout<<"Arithmetic Operatios";
cout<<"\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n5.Mode";
cout<<"\n\nEnter Your Choice:\n";
cin>>ch;

switch(ch)
{
case 1:
{
cout<<"\nEnter Two Value Ie:- Value Of A And B ";
cin>>a>>b;
rem=a+b;
cout<<"\n  Result = "<<rem;
cout<<"\n";
}
break;

case 2:
{
cout<<"\nEnter Two Value Ie:- Value Of A And B";
cin>>a>>b;
rem=a-b;
cout<<"\n  Result = "<<rem;
cout<<"\n";
}
break;

case 3:
{
cout<<"\nEnter Two Value Ie:- Value Of A And B";
cin>>a>>b;
rem=a*b;
cout<<"\n  Result = "<<rem;
cout<<"\n";
}
break;

case 4:
{
cout<<"\nEnter Two Value Ie:- Value Of A And B";
cin>>a>>b;
if(a>=b)
{
rem=a/b;
cout<<"\n  Result = "<<rem;
cout<<"\n";
}
else
cout<<"\nt 1st Varable Should Be Greater Than 2nd.  !!!";
cout<<"\n";
}
break;

case 5:
{
cout<<"\nEnter Two Value Ie:- Value Of A And B";
cin>>a>>b;
if(a>=b)
{
q=a/b;
rem=a-(b*q);
cout<<"\n  Result = "<<rem;
cout<<"\n";
}
else
cout<<"\nt 1st Varable Should Be Greater Than 2nd.  !!!";
cout<<"\n";
}
break;
}

return 0;
}

Output:-


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment