Machine-translated by Google. Questions are authored in English.
Top

Discussion

Anyone of the following can be used to declare a node for a singly linked list and “NODEPTR nodePtr;” can be used to declare pointer to a node using any of the following

/* First declaration */
typedef struct node
{
 int data;
 struct node *nextPtr;
}* NODEPTR;
 
/* Second declaration */
struct node
{
 int data;
 struct node * nextPtr;
};
typedef struct node * NODEPTR;

 

  • A.TRUE
  • B.FALSE

Answer: A

Correct answer: TRUE

Both work. In the first, the member is declared as struct node *nextPtr - the tag is available inside its own definition, even though the typedef name is not - and NODEPTR is defined by the same declaration. In the second, the structure is completed first and the typedef written afterwards. Either way NODEPTR nodePtr; declares a pointer to a node.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.