Languages [TCS Placement]: Sample Questions 107 - 109 of 131

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 107

Edit

Describe in Detail

Essay▾

What are linked list?

Explanation

  • A linked list is composed of nodes that are connected with one-another.
  • In C programming, linked lists are created using pointers.
  • Linked lists is efficient way of utilizing memory for storage.
  • Linked list consists of sequence of nodes.
  • Each node is composed of two fields: data field and reference field pointing to the next node.
  • Each node in the list is also called an element.
Given the Image is Define the C Linked List Example

Question 108

Edit

Write in Short

Short Answer▾

Difference between const char ⚹ p and const ⚹ char p

Explanation

  • const char ⚹ p - This is a pointer to a constant character. Program cannot change the value pointed by p, but it can change the pointer p itself. ⚹ p = ‘S’ is illegal. p = “Test” is legal. Note - char const ⚹ p is the same.
  • const ⚹ char p - This is a constant pointer to non-constant character. You cannot change the pointer p, but can change the value pointed by p. ⚹ p = ‘A’ is legal. p = “Hello” is illegal.

Question 109

Edit

Write in Short

Short Answer▾

Can static variables are declared in a header file?

Explanation

  • You can՚t declare a static variable without defining it as well.
  • This is because the storage class modifiers static and extern are mutually exclusive.
  • A static variable can be defined in a header file, but this would cause each source file that included the header file to have its own private copy of the variable, which is probably not what was intended.
  • The static variables don՚t have external linkage which means they cannot be accessed outside the translation unit in which they are being defined.

Developed by: