(h) If a five-digit number is input through the keyboard, write a program to reverse the number.

Let Us C by Yashwant Kanetkar

 
Solution By Muhammad Kaleem UIlah



                                                                  Exercise Questions 
[H] Write C programs for the following:
(h) If a five-digit number is input through the keyboard, write a program to reverse the number.

#include <stdio.h>

#include <stdlib.h>

 

int main()

 

{

    int num,rem1,rem2,rem3,rem4,rem5,rev;

    printf("\n\t\t Enter Your Favourite 5 Digits =");

    scanf("%d",&num);

    rem1=num/10000;

    num=num%10000;

    rem2=num/1000;

    num=num%1000;

    rem3=num/100;

    num=num%100;

    rem4=num/10;

    num=num%10;

    rem5=num;

    rev=rem5*10000+rem4*1000+rem3*100+rem2*10+rem1*1;

    printf("\n\t\t Your Reverse Number is =%d\n",rev);

    return 0;

}

Comments

Popular posts from this blog

EXERCISE 01 Complete Solved LET US C by Yashwant Kanetkar

(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.

(g) If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)