Write a C++ program that allows a user the option of using two mini programs. Th
ID: 3694733 • Letter: W
Question
Write a C++ program that allows a user the option of using two mini programs. The two mini programs should be as follows: 1. Write a program to simulate a simple calculator. It should accept two numbers from the user as well as the required operation to be performed. The basic operations that should be implemented are: addition, subtraction, division and multiplication. 2. Write a program that allows the user to input the radius, diameter, or area of a circle. The program should then calculate the other two based on the input.Explanation / Answer
Arthimetic Operations
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int number1,number2;
char ch;
clrscr();
cout<<"Enter two integer values ";
cin>>number1>>number2;
cout<<"+) Addition -)Subtraction *)Mulitiplication /)Division %)Module ";
cin>>ch;
switch(ch)
{
case '+' : cout<<"Addition :"<<number1+number2;
break;
case '-' : cout<<"Subtraction : "<<(number1-number2);
break;
case '*' : cout<<"Multiplication : "<<(number1*number2);
break;
case '/' : cout<<"Division : "<<(number1/number2);
break;
case '%' : cout<<"Module : "<<(number1%number2);
break;
default : cout<<"wrong choice";
}
getch();
}
Area of Circle:
#include<iostream.h>
#include<conio.h>
void main()
{
float radius;
clrscr();
cout<<"Enter radius ";
cin>>radius;
cout<<"The Area of Circle : "<<(3.14*radius*radius)<<endl;
cout<<"The Diameter of Circle : "<<(2*radius);
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.