πŸ“Š C Programming
Q. What will be the output of the following C program?
Code:
#include <stdio.h>

int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%ld", sizeof(x)/sizeof(x[0]));
    return 0;
}
  • (A) 3
  • (B) 4
  • (C) 5
  • (D) 6
πŸ’¬ Discuss
βœ… Correct Answer: (C) 5

Explanation: The statement sizeof(x)/sizeof(x[0]) can be used to get the total numbers of elements, sizeof(x) will return the size of array while sizeof(x[0]) will return the size of first element i.e., size of the type. Their division will return the total number of elements.

Explanation by: Team MCQ Buddy
The statement sizeof(x)/sizeof(x[0]) can be used to get the total numbers of elements, sizeof(x) will return the size of array while sizeof(x[0]) will return the size of first element i.e., size of the type. Their division will return the total number of elements.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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