#include<stdio.h>
#include<conio.h>
int main()
{
int num,a,b,c,d;
printf("Enter a four digit number : ");
scanf("%d", &num);
d=num%10;
c=(num/10)%10;
b=(num/100)%10;
a=(num/1000)%10;
printf("\n%d is the of first and last digit of %d", a+d,num);
getch();
return 0;
}
Ad
Chapter - 2: C Instructions
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.
Ad
Ad