Ask Question
21 June, 10:58

Write a program that prompts the user to enter a four-digit integer and displays the number in reverse order. Here is a sample run:

Enter an integer: 5213

3

1

2

5

+5
Answers (1)
  1. 21 June, 12:56
    0
    Following are the code that is written in c language

    #include

    int main () / / main function

    {

    int n1, t; / / declaring variable

    printf (" Enter an integer : ");

    scanf ("%d",&n1); / / taking input

    while (n1>0) / / iterating over the loop untill the value of n is greater then 0

    {

    t=n1%10;

    printf ("%d", t);

    printf ("/n");

    n1=n1/10;

    }

    return 0;

    }

    Explanation:

    we taking an integer value n1 and iterating over the loop untill n1>0

    suppose n1=1234

    then t=n%10;

    means t=1234%10

    as % holds reminder means t=4

    then print the value of t means print 4

    and n1 becomes 123 which is > 0 again condition is checking and same process is follow untill n1>0

    output

    Enter an integer: 5213

    3

    1

    2

    5
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that prompts the user to enter a four-digit integer and displays the number in reverse order. Here is a sample run: Enter ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers