Calculate the countdown count of a positive number entered on the keyboard assuming that the standard input contains a sequence of non-zero, zero-ended digits (check if they are really digits).
Example:
Entry: 1 9 7 4 0
Display: 4791


Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
#include <conio.h>

void main()
{
	int  X;     
 	long DECIMAL=1; 
 	long RESULT=0;  

	printf("Enter a sequence of digits ended with 0 \n");
 	do
    	{
     		scanf("%d", &X);

     		if (X<0||X>9)
        		printf("\a");
     		else if (X)
        	{
         		RESULT += DECIMAL*X;
         		DECIMAL *= 10;
        	}
     		else
       			 printf("The value in reverse %ld\n", RESULT);
    	}while (X);

	getch();
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Prime number