Languages [3i Infotech Placement]: Sample Questions 428 - 429 of 546

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 428

Edit

Describe in Detail

Essay▾
  1. main ()
  2. {
  3.     char ⚹q;
  4.     intj;
  5.     for (j =0; j<3; j ++ )
  6.     scanf (%s (q +j), );
  7.     for (j =0; j<3; j ++ )
  8.     printf (%c, ⚹(q +j) );
  9.     for (j =0; j<3; j ++ )
  10.     printf (%s (q +j), );
  11. }

Explanation

  • In a program we have only one pointer to type char and since we take input in the same pointer thus we keep writing over in the same location, each time shifting the pointer value by 1.
  • Suppose the inputs are MOUSE, TRACK and VIRTUAL.
  • Then for the first input suppose the pointer starts at location 100 then the input one is stored as

    M O U S E ⧵0

  • When the second input is given the pointer is incremented as j value becomes 1, so the input is filled in memory starting from 101.

    M T R A C K ⧵0

  • The third input starts filling from the location 102

M T V I R T U A L ⧵0

Table Showing the Program
printf (% c, ⚹ (q + j) ) ;The first printf prints the values at the position q, q + 1 and q + 2 = M T V
printf (% s (q + j) ,) ;The second printf prints three strings starting from locations q, q + 1, q + 2, i.e.. MTVIRTUAL, TVIRTUAL and VIRTUAL.

Question 429

Edit

Write in Short

Short Answer▾

What is a NULL Pointer? Whether it is same as an uninitialized pointer?

Explanation

  • Null pointer does not point to anything in the memory.
  • Null is defined as (void ⚹) 0.
  • Uninitialized pointer on the other hand is pointing to memory location but the pointer values are not assigned.

Developed by: