Online course

C++

TRAINING

1) Write a while loop statement to display values 100 90 80 …20 10

2) Write a while loop statement to display all the digits from a given number x, in reverse order.
Example: Input x= 321 Output 1 2 3

Training solutions

1) i=100;
while(i>=10)
{
cout<<i<<” “;
i=i-10;
}

2) while(x!=0)
{
cout<<x%10<<” “;
x=x/10;
}