Programming

# Four-digit number and display them in reverse order

Write a c program where program should read four digit number and display those entered number into reverse order.

## C Code

`#include<stdio.h>#include<conio.h>int main(void){        int number;        printf("Enter a four digit number:");        fflush( stdout );        scanf("%d", &number);        printf("the number in reversed order:");        printf("%d", number%10);        number = number/10;        printf("%d", number%10);        number = number/10;        printf("%d", number%10);        number = number/10;        printf("%d", number%10);        return 0;}`

## Output

When a user enters the value 1234
there is printf(“%d”,number%10); statement is used. It shows the value 4 because when 1234 is divided by 10 remainders is 4.
after that number = number / 10 display value 4…
the value of the number becomes 123 this process is repeated 3 times and the final output will be 4321

Write a C program to read a three-digit number and display it in reverse order.

## C Code

`#include<stdio.h>#include<conio.h>void main(){        int number;        printf("Enter a three digit number:");        fflush( stdout );        scanf("%d", &number);        printf("the number in reversed order:");        printf("%d", number%10);        number = number/10;        printf("%d", number%10);        number = number/10;        printf("%d", number%10);        getch();}`

#### Tuts

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

## You may also like

Programming

Programming

#### Calculate the Factorial by Using Recursion

• January 26, 2016