Populating an array with 100 integers in C -


this question has answer here:

i taking free cs50 online class. in 1 of video tutorials, teacher mentions ability fill array 100 integers, , practice. trying exact thing right , having difficult time figuring out.

note: have seen answers including scanf functions , pointers. way solve it, or can solved without scanf , pointer?

this barely closest can get...

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <stdlib.h>  int main(void) {  int fill_array[100];  for(int = 0; <= 100; i++) {     fill_array[99] = i;     printf("%i", fill_array[i]); } } 

prints out ton of random numbers , error:

fillingarray.c:14:18: runtime error: index 100 out of bounds type 'int [100]' 665999424 

it should :

for(int = 0; < 100; i++) 

there 1 more error in loop, fill array should :

fill_array[i] = i; 

the code should

int fill_array[100];  for(int = 0; < 100; i++) { fill_array[i] = i; printf("%i", fill_array[i]); } 

Comments