Search This Blog

Loading...

C Program to Reverse Number

//Write a program to reverse number.
//Code for Program to reverse number in C Programming

#include<stdio.h>
void main()
{
        int number,sum=0,rem;
        printf("Enter the number =>");
        if(scanf("%d",&number)==1)
        {
                sum=0;
                for( ;number>0; )
                {
                rem=number%10;
                sum=sum*10+rem;
                number=number/10;
                }
                printf("The number is =>%d",sum);
        }
        else
        {
        printf("entet correct value");
        }

}

Output:
Enter the number =>23
The number is =>32

No comments:

Post a Comment