hey all... new programmer here....
i am supposed to write a program that takes a number as a single variable and do a math equation with EACH number...
example...
int number[4]
int main(void)
{
printf("enter number;
scanf("%i", &number);
}
ok, no problem....
here is the problem....
if i enter the number 1234,
i have to take the first digit "1" and add 7 to it...
then i have to take the second digit and do the same this,
and so on to the fourth digit....
just to make sure i am getting the correct values to do my equation with i try doing the following....
printf("%i\n", number[0];
printf("%i\n", number[1];
printf("%i\n", number[2];
printf("%i\n", number[3];
i expected to get the following result:
1
2
3
4
instead i get....
1234
0
0
0
when i print out the value it gives me the whole array instead of just the element....
i need serious help...
thanks to those who take mercy on me...
sean



LinkBack URL
About LinkBacks
;



