Reverse a number | User given | C-Program

Reverse a number:

Tips:

1.Take variable.
2.Use while loop.
3.Divide the value taken in variable.


 

Code:

#include<stdio.h>

void main()

{
    int a,b=0,c;

    printf("Enter a number:\n");

    scanf("%d",&a);

    while(a!=0)

    {
        c=a%10;

        b=b*10+c;

        a/=10;
    }

    printf("The reverse : %d",b);

    getch();
}

Output:

Comments

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :