#include <stdio.h> main() { unsigned int a,b=0; printf("Number:"); scanf("%d",&a); while (a!=0) { b=b*10+a%10; a=a/10; } printf("Reversed number:%u\n",b); getch(); return 0; } this code displays the number in reverse order,
b = b * 10 + a% 10; a = a / 10; explain pzhl what occurs in these two lines.
The program works all the rules, but I do not quite understand what kind of calculations occur with b if it is zero.
scanf("%d",&a,b);- this is not a mistake, but it is nonsense. Also:%dformat forunsigned int? Forunsigned int, the format is%u. Andint main(void), notmain(). - AnTa%10is the last digit ofa. Next,a/10is the number ofawithout the last digit. Sincea=a/10;removes the last digit froma,while (a!=0)means "so far there are unprocessed digits ina". - HolyBlackCat