Q. What will be the output of the following C program?

Code:
#include <stdio.h>

int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%d", x[3]);
    return 0;
}
  • (A) 0
  • (B) 30
  • (C) Garbage value
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) 0
Explanation: In C language, when an array is partially initialized at the time of declaration then the remaining elements of the array is initialized to 0 by default.
Explanation by: Team MCQ Buddy
In C language, when an array is partially initialized at the time of declaration then the remaining elements of the array is initialized to 0 by default.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
273
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Team MCQ Buddy
Publisher
πŸ“ˆ
96%
Success Rate