0

Can u help me

Write a program that inputs two numbers and an operator in main function and passes them to a function. The function applies arithmetic operation on two number on the basis of the operator entered by user using switch statement.

9th Mar 2022, 3:15 PM
samnew
samnew - avatar
10 Respuestas
11th Mar 2022, 4:53 AM
aewerdev
aewerdev - avatar
0
In which language? in anyways, You need to add your try here... Tag the language..!
9th Mar 2022, 3:19 PM
Jayakrishna 🇮🇳
0
c++
9th Mar 2022, 3:19 PM
samnew
samnew - avatar
0
What help you need then?
9th Mar 2022, 3:21 PM
Jayakrishna 🇮🇳
0
public int op(int a , int b , String op){ int cal =0; switch(op){ case "+": return a+b; break; case value "-": return a-b; break; case value "*": return a*b; break; case value "/": return a/b; } }
9th Mar 2022, 3:34 PM
samnew
samnew - avatar
0
How do i finish this
9th Mar 2022, 3:35 PM
samnew
samnew - avatar
0
include cpp header file properly which is required to compile your program then inside main function write statements for user input for two number and declare one more variable which type will be char type and pass these values to op function. but as your program showing that you have to do it via classes u using public.......?
9th Mar 2022, 4:10 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
samnew Is that c++ code or java.. May you copied it from java file..! C++ case values must be integral type. So you need to convert to int value if you want use strung as case option. it won't support string as cases. And syntax is : case value : But not case value '+' : as you using. It's error. break after return statement is no use. Convert to c++ code.. You can use a character instead of string in c/c++ case values like : Sample : int main() { char c = '+'; //check by different operator switch(c) { case '+' : cout<< 2+3; break ; default : cout << "Error"; } }
9th Mar 2022, 4:40 PM
Jayakrishna 🇮🇳
0
T u
9th Mar 2022, 4:57 PM
samnew
samnew - avatar
0
java code that contains colorful outputs
11th Mar 2022, 6:01 AM
Poonam Tarevadiya