I just showed you what the combined loop and array should look like in my last post. The last code that you posted is not how you should be doing things; once you get more than a few elements, it becomes really dumb to not use loops. I posted what that program would look like using loops; do you not understand it? I can explain it step by step if that's the case.
Just fyi, I've got 30 more minutes of being bored at work, then I may not be posting so often.
int main ()
int arr; //declares integer array with 15 elements
for (int i = 0; i < 15; i++) // i starts at 0, and will increase by 1 each time the loop runs
// once i reaches 15, the loop will stop executing, because arr is outside of our array
arr[i] = (i + 1) * 100; // In your test program you assign 100 to element 0,
// 200 to element 1, and so on
// this statement takes the element number (i), adds 1, then multiplies by 100 to get 100 for element 0, 200 for element 1, etc
char str = "c program"; // this is unchanged
for (int i = 0; i < 15; i++) // same loop as used before
printf("%d: %d\n", i+1, arr[i]); //we want to print 2 numbers, the element number + 1 and the value in the array at that element
//so we do i+1 to get "1" to print for the value in the 0th element
printf("string: %s\n", str); // this is unchanged
If your book doesn't adequately explain all this stuff, you should get a different book. My intro book taught me everything very clearly. Please keep asking questions until you understand this stuff. This board gives me stuff to do while I'm bored waiting for the 4 day weekend to start :)
What's the name of the book? I'll definitely buy it! sorry if i seem like you're just talking to a wall, i've literally only been doing C for the past 3 weeks. I'll keep post questions and once again, thanks for all the help.
I actually started with C++ and have never even looked at a C book; I just took what I knew of C++ and learned C from online stuff. There's honestly so much stuff online that you could learn pretty much any language without ever touching a book. cprogramming.com has good tutorials; here's one on loops: http://www.cprogramming.com/tutorial/c/lesson3.html. Some books just don't explain things clearly at all, and it's frustrating when those are the ones the professors choose.