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;
}
#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
Comments
Leave a comment