Monday, July 8, 2019

reverse of the given number

#include<stdio.h>
#include <string.h>

void reverse (long int n);
void main ( )
{
    long int num;
    printf ("Enter number ");
    scanf("%ld",&num);
    reverse(num);
    printf("\n");
}
void reverse (long int n)
{
    int rem;

    if(n==0)
        return;
    else
    {
        rem=n%10;
    printf("%d",rem);
        n/=10;
    reverse(n) ;
    }

}


output:

Enter number 12345
54321

No comments:

Post a Comment

python class topic video