Write a Program in C to implement function program of reverse number. Implement using with argument and with return value.

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

int rev(int);

void main()
{
  int a,no;
  clrscr();
  printf("Enter the number you want the reverse of : ");
  scanf("%d",&no);
  a=rev(no);
  printf("The reverse number is %d",a);
  getch();
}

int rev(int no)
{
  int rem,rev=0;
  while(no>0)
  {
    rem=no%10;
    rev=rev*10+rem;
    no=no/10;
  }
  return rev;
}

No comments:

Post a Comment