Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 115 - 117 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 115

C & C Plus Plus
Edit

Write in Short

Short Answer▾

Can a structure contain a pointer to itself?

Explanation

  • Yes, a structure can contain a pointer to itself

sturct name {int … struct name ⚹ ptr;} ;

  • This is called self referential՚s structure.

Question 116

C & C Plus Plus
Edit

Write in Short

Short Answer▾
  1. inti; main()
  2. {
  3.     intt;for ( t=4;scanf("%d",&i)-t;printf("%d",i)) printf("%d--",t--);
  4. }

If the inputs are 0,1, 2,3 find the output

Explanation

4 - 0

3 - 1

2 - 2

In the program

Table Shows the Program
int i;Define the global integer variable i.
int t;Define the integer variable t in main class.
for (t = 4; scanf ( “% d” , &i) -t; printf ( “% d” , i) )Given the for loop

Using the input values of 0,1, 2,3 for ‘scanf’ x = scanf ( “% d” , &i) -t the values during execution will be,

Table Shows the Program
tix
40-4
31-2
220

Question 117

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. #include<stdio.h>
  2. intgetVal()
  3. {
  4.     return1000;
  5. }
  6. voidmain ()
  7. {
  8.     intx=getVal();
  9.     printf(“x=%d”,x);
  10. }

Explanation

  • The program uses keyword “return” to return value a value in the caller function.
Table Showing the Program
int getVal ()

{

return 1000;

}

  • Define the getVal () function
  • This function returns 1000 .
int x = getVal () ;
  • Integer variable x defines the getVal () function.
printf ( “x =% d” , x) ;
  • Printf prints the value of x = 1000.

Developed by: