If four-digit number is input through the keyboard, write a program to obtain the sum of the first and the last digit of this number.
#include
main ()
{
int number, last_digit, first_digit, total;
printf ("Enter the number which is to be Work out: ");
scanf ("%d", &number);
last_digit = number % 10;
total = last_digit;
first_digit = (number / 1000) % 10;
total = total + first_digit;
printf ("The total of the first and the last digit of the entered number is: %d", total);
}
main ()
{
int number, last_digit, first_digit, total;
printf ("Enter the number which is to be Work out: ");
scanf ("%d", &number);
last_digit = number % 10;
total = last_digit;
first_digit = (number / 1000) % 10;
total = total + first_digit;
printf ("The total of the first and the last digit of the entered number is: %d", total);
}
10:11 AM |
Category: |
0
comments
Comments (0)