1 / 3
Dec 2016

I typed the following code and the result was wrong:

include

int main(void) {
int value[] = {1, 2, 88, 42, 99};
for (int i=0; i<3; i++) {
printf ("\n%d\n", value[i]);
}
return 0;
}

if any body can help.

  • created

    Dec '16
  • last reply

    Mar '17
  • 2

    replies

  • 794

    views

  • 3

    users

  • 1

    like

2 months later

Its not necessary that every time you will give the same set of numbers as input i.e, {1,2,88,42,99) . It may differ, that set no.shown in problem is only an example to make u understand.

14 days later

You must declare i in the first of program not in the body of for loop it will be like this.hope it help

int main(void) {

int i; //here is the change declare it must be here
int value[] = {1, 2, 88, 42, 99};

for ( i=0; i<3; i++) {

 printf ("\n%d\n", value[i]);

   }

return 0;
}