0

How to use arrays in c

16th Aug 2018, 4:07 PM
Ronak Paul
Ronak Paul - avatar
4 Answers
+ 1
int a[5] = {1,2,3,4,5}; printf("%d\n",a[1]); //prints 2 as array index starts from 0
16th Aug 2018, 4:39 PM
Suhail Pappu
Suhail Pappu - avatar
0
using the for function
16th Aug 2018, 4:40 PM
Ronak Paul
Ronak Paul - avatar
0
for (int i = 0; i < ARRAY_SIZE; ++i) do_something_with(a[i]); This will do something with all array members.
16th Aug 2018, 5:19 PM
Vlad Serbu
Vlad Serbu - avatar
0
https://code.sololearn.com/cV2cJ89sVK5d/?ref=app here i made an array, gave it some values in the for loop, and then used for loop to print out those values also this is my first code in C and not C++, feels weird
16th Aug 2018, 6:04 PM
Data
Data - avatar