Hi guys, I am new to programming and am quite enjoying it. I have been given a project where i need to write a program that asks for a 4 digit input from the user and then sorts out how many thousands, hundreds, tens and ones make up that number. This is what i have written so far but it is not working. I was wondering if anyone could help.
Code:
#include <stdio.h>
#include <stdlib.h>
int i = 0;
int main()
{
int sortingstring[4];
printf("Please enter a 4 digit number\n");
for (i=0;i<3;i++);
{
scanf("%d", &sortingstring[i]);
}
for ( i = 0; i < 3; ++i );
{
if (i==0);
{
printf("\n There are %d thousands in your number\n", sortingstring[0]);
}
if (i==1);
{
printf("\n There are %d hundreds in your number\n", sortingstring[1]);
}
if (i==2);
{
printf("\n There are %d tens in your number\n", sortingstring[2]);
}
if (i==3);
{
printf("\n There are %d ones in your number\n\n", sortingstring[3]);
}
}
system("PAUSE");
return 0;
}
Thanks alot
Sam