Q2 If a five-digit number is input through the keyboard, write a program to reverse the number.

Write a c program to reverse input digit

Program: 60

If a five-digit number is input through the keyboard, write a program to reverse the number.| Let us C Solution

 

#include<stdio.h>
int main()
{
    int number=0, n;
    printf("Enter a number: ");
    scanf("%d", &n);
    while(n!=0)
    {
        number = number * 10;
        number = n % 10 + number;
        n = n/10;
    }
    printf("%d", number);
    return 0;
}

Output

 Enter a number: 12345
 54321

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.