In C, when there are many repeated values, we can use a shorthand array notation to define array. Below program demonstrates same.
1 1 1 1 0 0 2 2 2 2
Note that middle gap of 2 is automatically filled with 0.
This article is contributed by Kaushik Annangi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Basics of File Handling in C
- Segmentation Fault (SIGSEGV) vs Bus Error (SIGBUS)
- Accessing array out of bounds in C/C++
- strcpy in C/C++
- strcmp() in C/C++
- How to pass an array by value in C ?
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Variable Length Arrays in C and C++
- How to write long strings in Multi-lines C/C++?
- How to pass a 2D array as a parameter in C?
- fseek() vs rewind() in C
- puts() vs printf() for printing a string
- Data type of case labels of switch statement in C++?
- Do not use sizeof for array parameters
- Storage for Strings in C