Homework Help Question & Answers

Write a program which gets user choice for addition, subtraction, multiplication and division with characters ’+’,...

Write a program which gets user choice for addition, subtraction, multiplication and division with characters ’+’, ’-’, ’*’, and ’/’ respectively. This program should keep asking for two numbers and a choice to perform such operations inside a loop which can be only stopped by entering ’q’.

I've been working out of code blocks and now I'm not sure how to go about this

iew Search Project Build Debug Fortran wwSmith Tools Tools+ Plugins DoxyBlocks Settings Help maino: int -NM .* DACCEDCOQI SC

iew Search Project Build Debug Fortran wwSmith Tools Tools+ Plugins DoxyBlocks Settings Help maino: int -NM .* DACCEDCOQI SC *main.cpp x Files FSymbols o #include <iostream> using namespace std; rces main.cpp main.cpp int main() int first, second, add, substract, multiply: float divide; PROBEWN cout<<first; cin >> second; add = first + second; substract = first - second; multiply = first * second; divide = first / (float) second; return 0; Logs & others Code::Blocks X Search results X Cccc X Build log x Build messages X CppCheck/Vera++ X C ppCheck/Vera++ messag File Line 0 \Users\Dael C:\Users\Dag Message === Build: Debug in hw2.4 (compiler: GNU GCC Compiler) ==- In function 'int main()': error: no match for operator>> (operand types are std::ostream' (aka'atd::basic os.. note: candidate: 'operator>>(int, int)' <built-in note: no known conversion for argument 1 from std::ostream' (aka 'std::basic ostre 0 on 5 C:\Users\Dael... 0 Insert Mod
0 0
Add a comment
Answer #1

Sign Up to Unlock the answer FREE

Already have an account? Log in

#include<iostream>

int main()

{

char oper;

int fno,sno;

while(1)

{

int res;

cout<<"enter operator \n";

cin>>oper;

if (oper=='q')

{

break;

}

else

{

cout<<"enter first number \n";

cin>>fno;

cout<<"enter second number \n";

cin>>sno;

switch(oper)

{

case '+':

res=fno+sno;

cin>>res;

break;

case '-':

res=fno-sno;

cin>>res;

break;

case '*':

res=fno*sno;

cin>>res;

break;

case '/':

res=fno/sno;

cin>>res;

break;

default:

cout<<"invalid operator \n";

break;

}

}

}

}

Add a comment
Know the answer?
Add Answer to:
Write a program which gets user choice for addition, subtraction, multiplication and division with characters ’+’,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coin

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write below code in C++ using Visual Studio. Write program that uses a class template...

    Please write below code in C++ using Visual Studio. Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 • Hint: Use vectors and vector functions to store the set of items 2. Get the number of items in the...

  • what would be the solution code to this problem in c++? The Problem Write program that...

    what would be the solution code to this problem in c++? The Problem Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 Hint: Use vectors and vector functions to store the set of items 2. Get the number of...

  • Write a program in C++ that uses a class template to create a set of items....

    Write a program in C++ that uses a class template to create a set of items. . . The Problem Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 Hint: Use vectors and vector functions to store the set of...

  • How to solve this Problem in C++ . The Problem Write program that uses a class...

    How to solve this Problem in C++ . The Problem Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 Hint: Use vectors and vector functions to store the set of items 2. Get the number of items in the set...

  • Write a C++ program to validate computer user-ids and passwords. A list of valid ids and...

    Write a C++ program to validate computer user-ids and passwords. A list of valid ids and passwords (unsorted) is read from a file and stored in a Binary Search Tree (BST) of UserInfo objects. When user-ids and passwords are entered during execution, this BST is searched to determine whether they are legal. Input (file): UserInfo records for valid users Input (keyboard): Ids and passwords of users logging in Output (screen): Messages indicating whether user-ids and passwords are valid, as well...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

  • Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that...

    Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
Active Questions
ADVERTISEMENT