Write a program that displays the digit of the tens of a number entered on the keyboard. Same question for the hundreds.
Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
int main()
{
double x;
printf("Enter a number: ");
scanf("%lf", &x);
printf("Tens of %.2lf = %d\n", x, ((int)x %100 ) /10);
printf("Hundreds of %.2lf = %d\n", x, ((int)x %1000 ) /100);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Reverse level order