Question

What is the difference between these two programs? #include <iostream> using namespace std; int DontPanic(int &...

What is the difference between these two programs?

#include <iostream>

using namespace std;

int DontPanic(int & x);

int z = 10;

void main()

{

char x = 'y';

int y = 5;

int z = 100;

y = DontPanic(z);

cout << x << " " << y << " " << z << endl;

}

int DontPanic(int & x)

{

int * p;

p = & z;

x = (*p)++ + 1;

cout << x << " " << *p << " " << z << endl;

return --z;

}

and

#include <iostream>

using namespace std;

int DontPanic(int & x);

int z = 10;

int main()

{

char x = 'y';

int y = 5;

int z = 100;

y = DontPanic(z);

cout << x << " " << y << " " << z << endl;

}

int DontPanic(int & x)

{

int * p;

p = & z;

x = (*p)++ + 1;

cout << x << " " << *p << " " << z << endl;

return --z;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
only difference between these program is
in first program return type of main is declared as void.
where as in second program, return type of main is declared as int.

but, There won't be any change in the output.
Add a comment
Know the answer?
Add Answer to:
What is the difference between these two programs? #include <iostream> using namespace std; int DontPanic(int &...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT