Answer to Question #283795 in C++ for Abdullah

Question #283795

Dry Run the given code:


 int num,r,sum=0,t;


    cin >> num;

     

    for(t=num;  num!=0;  num=num/10)

    {

         r=num % 10;  

         cout<<r<<endl;

         sum=sum*10+r;

         cout<<sum<<endl;


    }




1
Expert's answer
2021-12-31T01:41:51-0500

It will prompt the user to enter value of num on screen and will continually divide num by 10 in a for loop and printing mode value of num and 10.the mode will be stored in variable r.The process will repeat till num is zero that is when the loop will be exited.

It will also print sum which is accumulated from the formula sum=sum*10+r


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