Program to print number in reverse order

//Program to print four digit number in reverse order
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,e,f;
clrscr();
printf("Enter a Four Digit number ");
scanf("%d",&a);
b=a/1000;a=a%1000;
c=a/100;a=a%100;
d=a/10;a=a%10;e=a;e=e*1000;d=d*100;c=c*10;f=b+c+d+e;
printf("Number in reverse order is as %d",f);

getch();
return 0;

}


OR

//Program to print any number any reverse order
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,i,j;
  clrscr();
  printf("Enter the Integer\n");
  scanf("%d",&n);
  for(i=0; n!=0;i++)
  {
     j=n%10;
     n=n/10;
     printf("%d",j);
  }  
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

No comments:

Post a Comment