Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 125 - 127 of 354

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

Question 125

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is the output of the following program?

  1. voidmain ()
  2. {
  3.     staticinti =i ++, j =j ++, k =k ++;
  4.     printf (i =%dj =%dk =%d, i, j, k);
  5. }

Explanation

In the program

Table Shows the Program
static int i = i ++ , j = j ++ , k = k ++ ;Here given the static integer variable i, j and k.

Since static variables are initialized to zero by default.

Then the all variables post increment of i, j and k are 1

printf (i =% d j =% d k =% d, i, j, k) ;Printf prints the value of i = 1 , j = 1 and k = 1

Question 126

C & C Plus Plus
Edit

Write in Short

Short Answer▾

Predict the output or error (s) for the following:

  1. main ()
  2. {
  3.     chara[4] =“HELLO”;
  4.     printf ( “%s”, a);
  5. }

Explanation

  • In this program
Table Showing the Program
char a [4] = “HELLO” ;
  • The character array a is of size 4 but the string constant requires 6 bytes to get stored.
  • So the compiler errors are accured.

Question 127

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is an incomplete type?

Explanation

  • Incomplete types refers to pointers non-available to be used in the implementation or they points to some location whose value is not available for modification. Example: int ⚹ i = 0x400 // i points to address 400 ⚹ i = 0; //set the value of memory location pointed by i.
  • Incomplete types are otherwise called uninitialized pointers.
Define the Incomplete Type Means Uninitialized Pointer

Developed by: