How to find sum of first and last digit
CODE
How to find sum of
first and last digit
If a six digit number is input through the keyboard, write a
program to obtain the sum of the first and last digit of this number
int main()
{
int
num,sum,r1,r2;
printf("\n enter the 6 digit number:");
scanf("\n %i",&num);
r1=num%10;
r2=num/100000;
sum=r1+r2;
printf("\n sum of first and last digit of %d is %d",num,sum);
}
Output:
enter the 6 digit number:
123456
sum of first and last digit
of 123456 is 7
How to find sum of first and last digit
Reviewed by Unknown
on
December 14, 2018
Rating:
No comments:
If you have any doubt or query ,comment below: