Code Blocks | Sololearn: Learn to code for FREE!

0

Code Blocks

Can you please help me out I need to create a simple calculator using if statement in code blocks that contains a modulus function.

4/19/2021 3:40:56 PM

Huzaifa Bhyat

9 Answers

New Answer

+1

//Calculator #include<iostream> using namespace std; int main() { float var1, var2, Result; //opt stands for operator char opt; cout << "Entre the first number" << endl; cin >> var1; cout << "Entre the secound number" << endl; cin >> var2; cout << "Entre operator (+,-,*,/,%)" << endl; cin >> opt; if (opt == '+') Result = var1 + var2; else if (opt == '-') Result = var1 - var2; else if (opt == '*') Result = var1 * var2; else if (opt == '/') Result = var1 / var2; else if (opt = '%') cout << "The remainder of " << var1 << "divided by " << var2; cout << " is " << var1 / var2 << " and has a remainder of " << var1 % var2 << endl; cout.precision(2); cout << " The result of " << var1 << " and " << var2 << " = " << Result; return 0; }

+1

Use == in % operator also

0

Okay, can you post your attempt?

0

Please specify the language too

0

Language C++

0

This operator is giving me a problem %

0

Thank you

0

I tried it but it didn't work

0

Can't you change the ' into " ?