Blogroll

Showing posts with label Important Interview Questions with Answers C - 1. Show all posts
Showing posts with label Important Interview Questions with Answers C - 1. Show all posts

Important Interview Questions with Answers C - 1

Saturday 26 May 2012


1.Given the Following program fragmentmain ()
{

   
int i, j, k;

   
i = 3;

   
j = 2 * (i + +);

   
k = 2 * (+ + i);
}
which one of The Given option is correct?
a) i = 4, j = 6. b) j = 6, k = 10.
c) i = 5, k = 6. d) j = 6, k = 8.
Answer: b
Explanation: In the term j = 2 * (i + +) the value of i is incrementing and Used Before in expression k = 2 * (+ + i); Will Get Used incremented first and then in the words



 
2. How Many Times Will Run the loop below

   
main ()

    
{

     
int i;

      
i = 0;

    
do

    
{

         
- I;

          
printf ("% d", i);

          
i + +;

   
} While (i> = 0)
}
a) 1
b) Infinite
c) 0
d) Compilation Error
Answer: b
Explanation: In Every iteration value of i is then incremented and decremented so restes 0 and hence has Infinite Loop.



 
3. switch (option) {
case 'H': printf ("Hello");
case 'W': printf ("Welcome");
case 'B': printf ("Bye");

                 
break;

          
}
What would Be The output if option = 'H'?
a) Hello
b) Welcome Hello
c) Welcome Hello Bye
d) None of the Above
Answer: c
Explanation: If option = 'H' then the first box is true so "Hello" gets printed order There Is No Break After This statement box to come out of the switch statement so the program executes all statements aussi Other box and get Hello Welcome Bye printed.



 
4. Suppose a, b, c are integer variables with values ​​5,6,7 respectively. What is the value of the expression:

                  
! ((B + c)> (a + 10))
a) 1 b) 6
c) 15 d) 0

 
Answer: a

 
Explanation:

   
1. ! ((B + c)> (a + 10))

   
2. ! ((6 + 7)> (5 +10))

   
3. ! (13> 15) 13 is less Than 15 so it will return False (0).

   
4. ! (0). Not of 0 is 1.


5. Consider the following program,

              
main ()

              
{

                     
int i, j;

                     
for (i = 0, j = 5 j> 0, i <10; i + +, j -)

                          
printf ("\ nGyantonic.com");

               
}

   
How Many Times "Gyantonic.com" will get printed

   
a) 5 b) Compilation Error

   
c) 10 d) None Of The Above
Answer: c
Explanation: Status of hand for loop (j> 0, i <10) is separated by commas Which means clustering compile That Will use the value Which is at right hand side of comma ie of i <10 so the loop executes till Will the value of i is less Than 10.



 
6. What Will Be the output of the Following program?
main ()
{

    
printf (3 + "Gyantonic" 4);
}
a. Compilation Error b. ntonic
c. tonic d ic
Answer: d
Explanation: Gyantonic is a constant string and statement

    
printf (3 + "Gyantonic" 4) Will skip seven (3 + 4) characters of the string Before printing.



 
7. What Will Be the output of the Following program?
main ()
{

    
printf ("% c", "Gyantonic" [4]);
}
a. Compilation Error b. G
c. t d n
Answer: c
Explanation: Gyantonic is a constant string and character at index 4 Will get printed.



 
8. What Will Be the output of the Following program?
main ()
{

    
printf ("Gyantonic" "\ t" ". com");
}
a. Gyantonic. Com b.Gyantonic.com
c. Gyantonic \ t.com d. None of These
Answer: a
Explanation: printf () print Gyantonic then a tab and then print. Com. Sami is writing it as it did printf ("Gyantonic \ t.com");

 

Most Reading

Tags

Sidebar One