0

Can you guys help me out ? The result of sum is 0 after I choose the variables and select s

#include<iostream> #include<cmath> using namespace std; void operations( int a, int b){ int sum; sum =a+b; int product; product=a*b; } int main(){ int a,b; int sum; int product; char calc; cout<<"choose varaibles"; cin >> a>>b; cout<<" Choose operation"; cin>> calc; if (calc=='s') cout<<" sum is"<<sum; else if (calc=='p') cout<<" product is "<<product; operations(a,b); }

22nd Apr 2020, 3:09 PM
marya collegework
marya collegework - avatar
3 Respostas
0
marya collegework Why do link those extra link in question? Please remove and include only required links for question.. About question, I just want say, please revise the topic of how functions are called and how to get back results... Your sum or product variable are not related to function.. call like this: cout<<"Sum is" <<operations(a, b, calc) ; In function, depending on calc variable return sun or product... Hoping you can do further..
22nd Apr 2020, 3:30 PM
Jayakrishna 🇮🇳
0
Sorry about that , it's my first time asking a question here , I thought that I have to include some links and thanks for your answer
22nd Apr 2020, 5:02 PM
marya collegework
marya collegework - avatar
0
marya collegework No problem.. That the information only to let you know.. If the question is not under the guidelines of SL, then it gets modified or even a chance to gets deteled.. So. Thanks for understanding and for the edit. Hoping you also got your answer of the question... And You're welcome...
22nd Apr 2020, 5:37 PM
Jayakrishna 🇮🇳