Pages

Tuesday, January 14, 2014

[H]. (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.

void main()
{
 int f, l, num, sum;
 clrscr();
 printf("Enter Four Digit Number : ");
 scanf("%d",&num);
 l=num%10;
 num=num/10;
 f=num%10;
 num=num/10;
 f=num%10;
 num=num/10;
 f=num%10;
 sum=f+l;
 printf("Sum Of First & Last Digit = %d",sum);
 getch();
}

No comments:

Post a Comment