
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
A shorthand array notation in C for repeated values?
An array stores number of same data type. For an array there may arise a situation when you need to store 2-3 values that are same i.e. 3,3,3,3 needs to be stored.
For this case, the programing language C has made a simple way to create an array with such repeated value to reduce the workload of the programmer.
Syntax
[startofRepeatingSeq … EndofRepeatingSeq]number Example : For 3 repeated 5 times ; [0 … 4]3
Example
#include <stdio.h> int main() { int array[10] = {[0 ... 4]3, [6 ... 9]5}; for (int i = 0; i < 10; i++) printf("%d ", array[i]); return 0; }
Output
3 3 3 3 3 0 5 5 5 5
- Related Questions & Answers
- Short hand array notation in C/C++
- How to create an array with non-default repeated values in C#?
- Queries for characters in a repeated string in C++
- Swap For Longest Repeated Character Substring in C++
- Queries for decimal values of subarrays of a binary array in C++
- How to create a vector with repeated values in R?
- Dot notation vs Bracket notation in JavaScript
- Evaluate Reverse Polish Notation in C++
- Shorthand property for setting all the column-rule-* properties
- Shorthand CSS property for flex-direction and flex-wrap
- How to access elements of an array using pointer notation in C#?
- Convert array with duplicate values to object with number of repeated occurrences in JavaScript
- GROUP BY array of document to get the count of repeated Age values
- Test array values for finiteness in Numpy
- Test array values for NaN in Numpy
Advertisements