Multiple choice

Which of the following is a wrong declaration of array?

  1. int digits[5]={1,2,3,4,5};

  2. float num[10];

  3. char color[3]={R,G,B};

  4. static float x[3]={2.5, 6.2, 7.8};

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Character array elements must be character literals enclosed in single quotes. Option C uses 'R,G,B' without quotes, which is incorrect syntax - it would be interpreted as variables, not characters. The correct syntax would be char color[3]={'R','G','B'};