If a four-digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of this number.
main()
{
int num,f,l,sum;
printf("Enter a four digit number\n");
scanf("%d",&num);
l=num%10; f=num/1000;
sum=f+l;
printf("Sum of first and last digit of %d is %d",num,sum);
}
No comments:
Post a Comment