X is an integer (X=2648). The print value of Y of the flowchart below is
Answers
Answer:
8462
Explanation:
y,x
8,264
84,26
846,2
8462,0
Answer:
The correct answer is 8962.
Explanation:
Program in C++
#include<iostream>
using namespace std;
int main()
{
int x;
cout<<"Enter a number : ";
cin>>x;
int y = 0;
do
{
y = (y * 10) + (x % 10);
x = x / 10;
}
while(x != 0);
cout<<y;
return 0;
}
Step by step calculation
Initially y = 0
Initially x = 2648
x y = (y * 10) + (x % 10) x = x / 10
2648 y = (0 * 10) + (2648 % 10) x = 2648 / 10
y = 0 + 8 x = 264
y = 8
264 y = (8 * 10) + (264 % 10) x = 264 / 10
y = 80 + 4 x = 26
y = 84
84 y = (84 * 10) + (26 % 10) x = 26 / 10
y = 840 + 6 x = 2
y = 846
2 y = (846 * 10) + (2 % 10) x = 2 / 10
y = 8460 + 2 x = 0
y = 8462
0
So, the final value of
#SPJ3