Thursday, September 4, 2008

C Program to REVESE AN INTEGER

//C program used to reverse an integer,count the no. of digits and calculate sum

#include < stdio.h>
#include < string.h>
#include < conio.h>
void main()
{
static char num[1000];
int sum=0;
int i=0,n=0;
printf("Enter the number:");
gets(num);// a=gets();
n=strlen(num);
printf("No of Digits=%d",n);

for(i= n-1;i> =0;i--)
{
printf("%c",num[i]);
}
printf("sum of digits:");
for(i=0;i< n;i++)
sum+= num[i];
printf("%d", sum);

getch();
}

0 comments: