y the ans is not 120? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

y the ans is not 120?

#include <iostream> using namespace std; int myFunc(int x) { int m = x+100; return m; } int main() { int var = 20; myFunc(var); cout << var<<endl; }

16th Jul 2016, 8:26 AM
Jithesh
1 Answer
+ 4
cuz you are printing var value that is 20.. calling of a function was at the wrong place try this now #include <iostream> using namespace std; int myFunc(int x) { x = x+100; return x; } int main() { int var = 20; cout << myFunc(var)<<endl; }
16th Jul 2016, 8:34 AM
Karan Luther
Karan Luther - avatar