program to reverse a number.

//program to reverse a number.
void main()
   int n,rem;
   printf("enter a number for 'n'\n");
logics in mind:-
>first we enter a number(for 'n').
->If we have number 123 then its reverse is 321. It means, first we have to get 3 then 2 and then 1.        ->For this, 
                 ->we have to divide by 10 to get last digit. 
                 ->Then we display that.
                -> to get second digit, we get first 12 and for this , we use 123/10.It is done to get integer                           part  only.
->We repeat this until the value reaches 0. We use loop for this as shown above in the code.                 

No comments:

Post a Comment