Knowee
Questions
Features
Study Tools

Which of the following declaration is illegal?a.int a = 0, b = 1, c = 2; int array[3] = {a, b, c};b.int size = 3; int array[size];c.int size = 3; int array[size] = {1, 2, 3};d.In appropriate

Question

Which of the following declaration is illegal?a.int a = 0, b = 1, c = 2; int array[3] = {a, b, c};b.int size = 3; int array[size];c.int size = 3; int array[size] = {1, 2, 3};d.In appropriate

🧐 Not the exact question you are looking for?Go ask a question

Solution

To determine which of the given declarations is illegal, let's analyze each option step by step:

a. int a = 0, b = 1, c = 2; int array[3] = {a, b, c}; This declaration is legal. It declares three integer variables a, b, and c, and initializes them with the values 0, 1, and 2 respectively. It also declares an integer array of size 3 and initializes it with the values of a, b, and c.

b. int size = 3; int array[size]; This declaration is legal. It declares an integer variable size and initializes it with the value 3. It also declares an integer array of size equal to the value of size.

c. int size = 3; int array[size] = {1, 2, 3}; This declaration is legal. It declares an integer variable size and initializes it with the value 3. It also declares an integer array of size equal to the value of size and initializes it with the values 1, 2, and 3.

d. Inappropriate This option is not a valid declaration and is considered inappropriate. It does not follow the syntax rules of the language.

Therefore, the correct answer is option d.

This problem has been solved

Similar Questions

Which of the following declarations is correct?int arr[3] = {1, 2, 3, 4};int arr[] = {1, 2, 3};int arr[3] = {1, 2};Both B and C

Which of the following statement(s) is/are correct about an array?  Tick all correct answer(s).  No partial marks and no negative marks.Select one or more:The expression num[1] designates the very first element in the array.The array int num[26]; can store 26 elements.The declaration num[SIZE] is allowed if SIZE is a macro.It is necessary to initialize the array at the time of declaration.

Which of the following statements correctly declares an array in Java? a. int[] numbers = new int(); b. int numbers[] = new int[10]; c. int numbers[10] = new int(); d. int numbers = new int[10];

Which of the following syntax correctly declares an Array in C/C++?int geeks;array geeks[20];geeks{20};int geeks[20];

Choose the correct way to declare 2D array.a.int x[3][4] = {0, 1 ,2 ,3 ,4 , 5 , 6 , 7 , 8 , 9 , 10 , 11};b.int x[3] = {0, 1 ,2 ,3 ,4 , 5 , 6 , 7 , 8 , 9 , 10 , 11}c.int x[4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}};d.None of the above

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.