What is an array in C?
An array stores many values of the same data type in continuous memory. Each value is reached with an index, and the index starts from 0.
#include <stdio.h>
int main(void) {
int marks[3] = {70, 85, 90};
printf("%d %d\n", marks[0], marks[2]);
return 0;
}
Output:
Output of the above program is
70 90
C does not check the array limits, so reading marks[5] is a bug. See C Arrays.
Learn more about the similar topics:
| Tutorials |
|---|
| C Arrays |
| C Two Dimensional Arrays |
| C Passing Arrays to Functions |
| C Strings |
| C String Input and Output |
| C String Functions |
| C strlen() Function |
| Interview Questions & Answers |
|---|
| What is an array in C? |
| How is a string stored in C? |
| How to reverse a string in C? |
| What is the difference between memcpy() and strcpy() in C? |