Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (fellowroot):

I'm trying to compile this code in C and it won't work. Can somebody help.

OpenStudy (fellowroot):

#include <stdio.h> void main() { int list[10] = {0}; for (int i=0; i<5; i++ ) list[2*i+1] = i+2; for (int i=0; i<10; i++ ) printf ("%3d", list[i]); } // main

OpenStudy (fellowroot):

The error happens when it gets to the "for" part.

OpenStudy (fellowroot):

oh fluttering apparently you can't fluttering do for(int i=0; .........) it needs to be for (i=0; ..........)

OpenStudy (anonymous):

problem in for loop see this: http://adf.ly/M2Tpi

OpenStudy (anoop27):

#include <stdio.h> void main() { int list[10] = {0}; for (int i=0; i<5; i++ ) list[2*i+1] = i+2; for (i=0; i<10; i++ ) printf ("%3d", list[i]); } // main --------------Problem Solved Now Compile the above program----------- Error in Code----> Multiple declaration for i in function main()

OpenStudy (fellowroot):

Thanks anoop27. I think it was my compiler. I used Dev C++ bloodshed. Apparently you can't do int i=0 inside a for loop with Dev C++ :/

OpenStudy (anoop27):

@Fellowroot ur welcome

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!