Hello
I try to implement in C the following: I wish to organize the following number: 1234 in a triangle form, let's say : 3
23
1234
The idea is to break the number in 4 digits , divide every digit in modulo 2 and keep the rest , getting rid of the digit and going to the following one, starting from x^0 , to x^3 ( units, tenth, hundreds , thousands), and finally printing them in the order i choose.
So, my program is:
#include<stdio.h>
int main(void)
{
unsigned long x;
unsigned x0,x1,x2,x3;
printf("please print your number:\n");
scanf("%lu",&x);
x0%10; //keep the units digit
x/10; // get rid of the units
x1%10; //keep the tenth
x/10; // get rid of tenth
x2%10; //keep the hundreds
x/10; //get rid of hundreds
x3%10; // keep the hundreds
x/10; // in x remain the thousands
printf(" %u\n",x2); // space , space, x2
printf(" %u%u\n",x2,x1); /space x2.x1
printf("%lu%u%u%u\n, x3,x2,x1,x0); /no space, x3,x2,x1,x0
return 0; }
And the result after input : 1234 , compile is : 3
34
1233
I can not understand where i am wrong , please help.
Thank you
Adrian