Ask Question
2 January, 14:25

What is the output of the following C+ + code?

#include

using namespace std;

void sum (int x, int y, int & z) { z = x + y; }

int main ()

{

int list1[3], list2[3];

int a = 5, b = 10, c = 0;

for (int i = 0; i < 3; i++)

{

list1[i] = i + 1;

list2[i] = i + 2;

}

//a sum (a, b, c);

cout << "c = " << c << endl;

//b sum (list1[0], list2[0], c);

cout << "c = " << c << endl;

//c sum (list1, list2, c);

cout << "c = " << c << endl;

//d for (int i = 1; i < 3; i++)

{

sum (list1[i], list2[i], c);

cout << "c = " << c << endl;

}

return 0;

}

+5
Answers (1)
  1. 2 January, 14:33
    0
    Your not including anything in your code.

    Explanation:

    According to your text all you have is #include. You didn't incldue any directives so you will get a error.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What is the output of the following C+ + code? #include using namespace std; void sum (int x, int y, int & z) { z = x + y; } int main () { ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers