In C What is the output include using namespace std void fu
In C++, What is the output ?
#include <iostream>
using namespace std;
void fun2(int& a, int& b, int c, int& d)
{
int temp;
temp = a;
a = b;
b = c;
c = d;
d = temp;
}
void main()
{
int a, b, c, d;
a = b = c = d = 0;
for(int i = 0; i < 2; i++){
fun2(a, b, c, d);
a += 4;
b -= 3;
c *= 2;
d -= 1;
}
cout << a << \" \" << b << \" \" << c << \" \" << d << endl;
}
Solution
Answer :
#include <iostream>
using namespace std;
void fun2(int& a, int& b, int c, int& d)
{
int temp;
temp = a;
a = b;
b = c;
c = d;
d = temp;
}
void main()
{
int a, b, c, d;
a = b = c = d = 0;
for(int i = 0; i < 2; i++){
fun2(a, b, c, d);
a += 4;
b -= 3;
c *= 2;
d -= 1;
}
cout << a << \" \" << b << \" \" << c << \" \" << d << endl;
}
Answer :
1 -3 0 3

