-->

Facebook

Jasper Roberts - Blog

Tuesday, March 31, 2015

Write a c program to reverse the digit.

PRACTICAL-SET-
2.  Write a prograto reverse the digit.


#include<stdio.h>
#include<conio.h>

void main()
{
    int num,r,reverse=0;
    clrscr();

    printf("Enter the number: ");
    scanf("%d",&num);

    while(num)
{
         r=num%10;
         reverse=reverse*10+r;
         num=num/10;
    }

    printf("Reverse of a given number is = %d",reverse);
getch();
}

OUTPUT:
Enter the number:  1234
Reverse of a given number is = 4321

No comments:

Post a Comment