Friday, August 16, 2019

WAP to find a reverse of number.

// Program

#include<stdio.h>
void main()
{
    int a,b,n;
    clrscr();
    printf("Enter any number:");
    scanf("%d",&n);
    b=0;
    while(n!=0)
    {
          a=n%10;
          b=(b*10)+a;
          n=n/10;
     }
    printf("Reverse of a number=%d",b);
    getch();
}

Sample Input/Output:

Enter any number:1234
Reverse of a number=4321

No comments:

Post a Comment

Write a program to find gcd of two numbers using recursion.

About:  The process in which a function calls itself is called recursion and the corresponding function is called as recursive function. ...