Program to accept a number and print the sum of given and Reverse number - 100 Most Important C# Programs

100 Most Important C# Programs

38. Program to accept a number and print the sum of given and Reverse number

Code:

# include <stdio.h>

# include <conio.h>

main( )

{

int a,b,n;

clrscr( );

printf(“enter a number:”)

scanf(“%d”,&n);

a=rev(n);

printf(“REVERSE OF A GIVEN

NUMBER IS %d”,a);

b=add(n,a);

printf(“\n sum of a given and reverse

number is %d”,b);

getch( );

}

int rev( int n)

{

int r,rev=0,s;

while(n>0)

{r

=n%10;

rev=rev*10+r;

n=n/10;

}r

eturn rev;

}

int add(int n, int a)

{

return n+a;

}