What will be the output of the following code?#include<iostream>using namespace std;void func(int a, int b) { cout << (a + b);}int main() { int a = 7; func(a, 12);}Options: Pick one correct answer from below12151929
Question
What will be the output of the following code?#include<iostream>using namespace std;void func(int a, int b) { cout << (a + b);}int main() { int a = 7; func(a, 12);}Options: Pick one correct answer from below12151929
Solution
The output of the code will be 19.
Here's the step by step explanation:
-
The main function is called first in C++ program.
-
In the main function, an integer 'a' is declared and initialized with the value 7.
-
Then, the function 'func' is called with two arguments: 'a' (which is 7) and 12.
-
Inside the function 'func', the two arguments are added together (7 + 12) and the result is printed out using 'cout'.
-
So, the output of the program will be 19.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.