Monday, 22 June 2015

Print reverse of a 3 digit number enter by user

/* print 3 digit  number in reverse order*/
#include<stdio.h>
#include<conio.h>
int main()
{
  int val,dig3,dig2,dig1,val1;
  clrscr();
  printf("Enter a three digit number ");
  scanf("%d",&val);
  val1=val;
  dig3=val%10; val=val/10;
  dig2=val%10;val=val/10;
  dig1=val;
  printf("the reverse of the number %d is %d%d%d",val1,dig3,dig2,dig1);
  getch();
  return 0;
}

This a how the program is written in a c compiler 




The output is shown as follows!!!





No comments:

Post a Comment