why do not it' output is 100? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why do not it' output is 100?

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

25th Sep 2017, 4:40 PM
Shivani Goyal
1 Answer
0
In a main method you define a var variable with the value 20. and call the myfunc with pass the variable var and initialize the variable with 100 not printed. and print the var which value is 20 not 100.
4th Jan 2018, 1:31 PM
tarun
tarun - avatar