(i) 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.
Let Us C by Yashwant Kanetkar
Solution By Muhammad Kaleem UIlah
(i) 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.
#include
<stdio.h>
#include
<stdlib.h>
int Main()
{
int num,rem1,rem2,rem3,rem4,sum;
printf("\n\t\t Enter Your Favourite 4
Digits =");
scanf("%d",&num);
rem1=num/1000;
num=num%1000;
rem2=num/100;
num=num%100;
rem3=num/10;
num=num%10;
rem4=num;
sum=rem1+rem4;
printf("\t\tThe Sum of first and last
digit = %d",sum);
return 0;
}
Comments
Post a Comment