Wednesday, April 17, 2013

Sum of first and last digit from given numbrs

Sum of first and last digit from  given numbers



#include<stdio.h>
int main()
{
int num,sum=0,i,lastDigit,temp=0;
printf("Enter any number: ");
scanf("%d",&num);
temp=num%10;
while(num!=0)
{
lastDigit=num;
num=num/10;
}
sum=temp+lastDigit;
printf("\nSum of first and last digit is:%d\n",sum);
}