Answer to Question #317318 in C++ for faizan.x

Question #317318



Dry run the following code and show the output in the end. Explain each step in your answer

void main()

{

int first, second, temp;

first= 25, second=12, temp=0;

temp = first;

first = second;

second = temp;

cout<< first<<endl;

cout<<second;

return 0;

}



1
Expert's answer
2022-03-24T07:49:17-0400
#include <iostream>
using nanespace std;

void main()
{
    int first, second, temp;
    first= 25, second=12, temp=0;  // Initialize 3 variable

    // Swap values holded in variables firs and second
    temp = first;                   // save value of first
    first = second;                 // assing first a new value
    second = temp;                  // assign a new value to the variable second

    // Print value of variables
    cout << first << endl;
    cout << second;

    return 0;
}

Output is

12

25


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog