Question
Download Solution PDFWhat is the correct syntax to declare a one-dimensional array 'students' of size 20 in C?
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFCorrect Syntax to Declare a One-Dimensional Array in C
Definition: In the C programming language, an array is a collection of elements of the same data type, stored in contiguous memory locations. A one-dimensional array is essentially a list of elements, and its declaration specifies the size and type of the array. The syntax to declare an array is crucial for proper functioning and memory allocation during the program's execution.
Correct Option Analysis:
The correct syntax to declare a one-dimensional array named students
of size 20 in C is provided in Option 2: int students[20];
.
This syntax is correct and adheres to the rules of array declaration in C. Let's break it down:
- int: This specifies the data type of the array elements. In this case, the array will store integers.
- students: This is the name of the array. It acts as an identifier through which the array elements can be accessed.
- [20]: This specifies the size of the array, i.e., the number of elements it can store. Here, the array can hold 20 integers.
The combination of these components ensures that the compiler knows the type of data being stored, the name of the array, and the size of memory that needs to be allocated for it. This makes int students[20];
the correct and standard way to declare a one-dimensional array of size 20 in C.
Additional Information: The elements of the array can be accessed using their indices. In C, array indices start from 0, so students[0]
refers to the first element, students[1]
to the second, and so on, up to students[19]
for the 20th element.
Last updated on Jul 2, 2025
-> The RRB JE CBT 2 Result 2025 has been released for 9 RRBs Zones (Ahmedabad, Bengaluru, Jammu-Srinagar, Kolkata, Malda, Mumbai, Ranchi, Secunderabad, and Thiruvananthapuram).
-> RRB JE CBT 2 Scorecard 2025 has been released along with cut off Marks.
-> RRB JE CBT 2 answer key 2025 for June 4 exam has been released at the official website.
-> Check Your Marks via RRB JE CBT 2 Rank Calculator 2025
-> RRB JE CBT 2 admit card 2025 has been released.
-> RRB JE CBT 2 city intimation slip 2025 for June 4 exam has been released at the official website.
-> RRB JE CBT 2 Cancelled Shift Exam 2025 will be conducted on June 4, 2025 in offline mode.
-> RRB JE CBT 2 Exam Analysis 2025 is Out, Candidates analysis their exam according to Shift 1 and 2 Questions and Answers.
-> The RRB JE Notification 2024 was released for 7951 vacancies for various posts of Junior Engineer, Depot Material Superintendent, Chemical & Metallurgical Assistant, Chemical Supervisor (Research) and Metallurgical Supervisor (Research).
-> The selection process includes CBT 1, CBT 2, and Document Verification & Medical Test.
-> The candidates who will be selected will get an approximate salary range between Rs. 13,500 to Rs. 38,425.
-> Attempt RRB JE Free Current Affairs Mock Test here
-> Enhance your preparation with the RRB JE Previous Year Papers.