MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Correct code to define a list C++?
A
Int[] scores = {15, 29, 4, 50};
B
int scores [4]= {15, 29, 4, 50}
C
int scores = (15, 29, 4, 50)
D
none of the above
Explanation: 

Detailed explanation-1: -In C language, a linked list can be implemented using structure and pointers . struct LinkedList int data; struct LinkedList *next; ; The above definition is used to create every node in the list. The data field stores the element and the next is a pointer to store the address of the next node.

Detailed explanation-2: -To create an array, define the data type (like int ) and specify the name of the array followed by square brackets []. To insert values to it, use a comma-separated list, inside curly braces: int myNumbers[] = 25, 50, 75, 100;

Detailed explanation-3: -int L = list(1, 2, 3, 4, 5); int a = L[0]; int b = L[1];

Detailed explanation-4: -int arr[] = 1, 2, 3, 4, 5; //Number of elements present in an array can be calculated as follows. int length = sizeof(arr)/sizeof(arr[0]);

There is 1 question to complete.