3i Infotech Placement: Sample Questions 1233 - 1234 of 1245

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

Question 1233

Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. #include<stdio.h>
  2. voidmain ()
  3. {
  4.     inta[2][2][2] ={ { 10, 2}, { 5, 6} };
  5.     int ⚹p, ⚹q;
  6.     p =&a[2][2][2];
  7.     q =⚹ ⚹⚹ a;
  8.     printf ( “%d…%d” ⚹p, ⚹q);
  9. }

Explanation

In the program

Table Shows the Program
int a [2] [2] [2] = { {10,2} , {5,6} } ;
  • Given the integer 2D array and values
int ⚹ p, ⚹ q;
  • Given the integer pointer and q
p = &a [2] [2] [2] ;
  • p = &a [2] [2] [2] declares only two dimensions 2D arrays.
  • But trying to access the third dimension (which was not declared) will print garbage values.
⚹ q =⚹ ⚹⚹ a;
  • q =⚹ ⚹⚹ a starting address of a is assigned integer pointer.
  • Now q is pointing to starting address of a.
  • If you print ⚹ q it will print first element of 3D array

Question 1234

Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. voidmain ()
  2. {
  3.     charch;
  4.     for(ch=0; ch<=127;ch++)
  5.     printf (“%c %d”, ch, ch);
  6. }

Explanation

Implementation dependent

In the program

Table Showing the Program
char ch;
  • Define the character variable ch.
for (ch = 0; ch <= 127; ch ++)
  • The char type may be signed or unsigned by default.
  • If it is signed- when ch ++ is executed ch reaches 127 and rotates back to -128
  • Thus ch is always smaller than 127.
printf ( “% c % d” , ch, ch) ;
  • Printf prints the value of ch

Developed by: