Given the following function in C++:
int main(void) {
int a = 2;
int b = myFunction(a);
a = b + 1;
b = myFunction(a);
cout << ”b = ” << b << endl;
return 0;
}
int z = myFunction(int x) {
static int n = 0;
n = n + 1;
int z = x + n;
return z;
}
What is printed by the cout on the screen?
Case:1
This program is getting Some syntax Errors
main.cpp: In function ‘int main()’: main.cpp:4:21: error: ‘myFunction’ was not declared in this scope int b = myFunction(a); ^ main.cpp:7:1: error: ‘cout’ was not declared in this scope cout << "b = " << b << endl; ^~~~ main.cpp:7:24: error: ‘endl’ was not declared in this scope cout << "b = " << b << endl; ^~~~ main.cpp: At global scope: main.cpp:10:20: error: expected primary-expression before ‘int’ int z = myFunction(int x) { ^~~ main.cpp:10:25: error: ‘myFunction’ was not declared in this scope int z = myFunction(int x) {
Case:2
If we ignore that
Get Answers For Free
Most questions answered within 1 hours.