Completely Solved C, C++ Programs Assignment.




C Program to accept a number and print the sum of given and Reverse number using function

Filed Under:

Problem 38. C Program to accept a number and print the sum of given and Reverse number using function.
#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;
}
return rev;
}
int add(int n, int a)
{
return n+a;
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments