Write a program find the sum of first and last digit
#include<stdio.h>
int main()
{
int n, i, sum=0, a;
printf("enter the number ");
scanf("%d",&n);
sum=sum+n%10;
while(n!=0)
{
a=n;
n=n/10;
}
sum=sum+a; //Assignment operator
printf("sum of first and last digit = %d ",sum);
return 0;
}
OUTPUT
enter the number 54
sum of first and last digit = 9
No comments:
Post a Comment