• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Input and Output

Question 31

C
#include <stdio.h>
// Assume base address of \"GeeksQuiz\" to be 1000
int main()
{
   printf(5 + \"GeeksQuiz\");
   return 0;
}
  • GeeksQuiz
     

  • Quiz
     

  • 1005
     

  • Compile-time error
     

Question 32

What does the following C statement mean? 
 

C
 scanf(\"%4s\", str);
  • Read exactly 4 characters from console.
     

  • Read maximum 4 characters from console.
     

  • Read a string str in multiples of 4
     

  • Nothing
     

Question 33

Consider the following ANSI C code segment: 

z=x + 3 + y->f1 + y->f2; 
for (i = 0; i < 200; i = i + 2) 

if (z > i) 

p = p + x + 3; 
q = q + y->f1; 
} else 

p = p + y->f2; 
q = q + x + 3; 


Assume that the variable y points to a struct (allocated on the heap) containing two fields f1 and f2, and the local variables x, y, z, p, q, and i are allotted registers. Common sub-expression elimination (CSE) optimization is applied on the code. The number of addition and the dereference operations (of the form y ->f1 or y ->f2) in the optimized code, respectively, are:
 

  • 403 and 102
     

  • 203 and 2
     

  • 303 and 102
     

  • 303 and 2
     

Question 34

Which of the following is true?
 

  • gets() doesn\'t do any array bound testing and should not be used. 
     

  • fgets() should be used in place of gets() only for files, otherwise gets() is fine
     

  • gets() cannot read strings with spaces
     

  • None of the above
     

Question 35

Predict the output?
C
int fun(char *str1){  char *str2 = str1;  while(*++str1);  return (str1-str2);}int main(){  char *str = \"GeeksQuiz\";  printf(\"%d\", fun(str));  return 0;}
  • 10
     

  • 9
     

  • 8
     

  • Random Number
     

Question 36

When a copy constructor may be called?

  • When an object of the class is returned by value.
  • When an object of the class is passed (to a function) by value as an argument.
  • When an object is constructed based on another object of the same class
  • When compiler generates a temporary object.
  • All of the above

Question 37

'C' Language can be used in ??

  • Both System Software and Embedded Systems

  • Only System Software

  • Only Embedded Systems

  • None

There are 37 questions to complete.

Last Updated :
Take a part in the ongoing discussion