Files
C-Bootcamp-Tutorial/A10/79-80. Print Reversed Number/main.c
T
2026-09-24 14:39:54 +02:00

35 lines
615 B
C

#include <stdio.h>
#include <stdlib.h>
// 531
// 135
// Units
// Tens
// Hundreds
int main()
{
int num;
int units, tens, hundreds;
int reversenum;
printf("Bitte geben sie eine dreistellige Zahl ein: \n");
scanf("%d", &num);
units = num % 10;
tens = (num / 10) % 10;
hundreds = num / 100;
printf("units: %d\n", units);
printf("tens: %d\n", tens);
printf("hundreds %d\n", hundreds);
reversenum = units * 100;
reversenum = reversenum + tens * 10;
reversenum = reversenum + hundreds;
printf("The reverse number is: %d\n", reversenum);
return 0;
}