(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



                                                                  Exercise Questions 
[H] Write C programs for the following:

(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

Popular posts from this blog

(k) A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer.

(j) In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total population, write a program to find the total number of illiterate men and women if the population of the town is 80,000.

EXERCISE 01 Complete Solved LET US C by Yashwant Kanetkar