C program to display given number in reverse order using while loop

 C program to display given number in reverse order using while loop
 


/**************************************

 C program to display given number in reverse order

 for example if user input is 123456789 then reverse= 987654321

 *************************************************/

 #include<stdio.h>

 #include<conio.h>

 void main()

 {

     int n,rem;

     clrscr();

     printf("Enter any number to print it in reverse order\n");

     scanf("%d",&n);

     printf("The reverse order of number %d is ",n);

     while(n!=0)

     {

         rem=n%10;

         printf("%d",rem);

         n=n/10;

         

     }

     printf("\n");

     printf("End of program");

 }


Enter any number to print it in reverse order

123456789

The reverse order of number 123456789 is 987654321

End of program




टिप्पणी पोस्ट करा

0 टिप्पण्या