The Student Room Group

Inputting inside a loop, Help please.

I'm trying to make a loop so that I can input the elements of an array by cycling through them and inputting using scanf in C but it seems to be skipping past the scanf line. Here is the loop:

{
for (i=0; i<=9; i++)
printf("input number %d\n",i);
scanf("%f",&xx);

}

many thanks.
Move the character "{" down so it comes after "for (i=0; i<=9; i++)"

i.e.

for (i=0; i<=9; i++)
{
printf("input number %d\n",i);
scanf("%f",&xx);
}

As it stands, the only thing in your for loop is the printf line.
(edited 11 years ago)

Quick Reply

Latest

Trending

Trending