MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Consider the following definition in c programming language.Which of the following c code is used to create new node? struct node{ int data; struct node * next;}typedef struct node NODE;NODE *ptr;
A
ptr = (NODE*)malloc(sizeof(NODE));
B
ptr = (NODE*)malloc(NODE);
C
ptr = (NODE*)malloc(sizeof(NODE*));
D
ptr = (NODE)malloc(sizeof(NODE));
Explanation: 

Detailed explanation-1: -The correct answer of this question is ptr = (NODE*)malloc(sizeof(NODE)). Explanation: Given-c code is used to create new node.

Detailed explanation-2: -The C programming language is a procedural and general-purpose language that provides low-level access to system memory. A program written in C must be run through a C compiler to convert it into an executable that a computer can run.

Detailed explanation-3: -

There is 1 question to complete.