If a four digit number is through the keyboard, write a program to obtain the sum of the first and the last digit of this number.


 #include<stdio.h>
void main()
{
int num,fd,sum,ld;
//programwithharsh//
printf("Enter a four digit number=");
scanf("%d",&num);
ld=num%10;
fd=num/1000;
sum=ld+fd;
printf("Sum of first and last digit=%d",sum);
}

The output will be

Post a Comment (0)
Previous Post Next Post