C Functions Questions and Answers

Take Exam

C Functions Questions with Answers provide an in-depth look at one of the most fundamental concepts in C programming. Understanding how to define, call, and manage user-defined and library functions is key to mastering structured programming. These C programming MCQs are widely used in technical interviews and coding tests conducted by companies like TCS, Wipro, and Infosys. Each question includes explanations to help you grasp parameter passing, recursion, return types, and scope. Practicing programming questions with answers strengthens your coding logic and prepares you for real-world software challenges. Download C programming MCQ PDFs and practice online to enhance your technical aptitude efficiently.

C Functions

Showing 10 of 151 questions

31. Which of the following would compute the square of x in C?

  • pow (2, x);
  • pow (x, 2)
  • x**2
  • power (x, 2)
Show Answer Report

32. All Standard C library <math.h> functions return data type ?

  • decimal
  • float
  • double
  • int
Show Answer Report

33. void show ( ) ; main ( ) { show ( ); } void show ( char *s) { printf ("%s\n", s); } What will happen when the above code is compiled and executed using a strict ANSI C compiler ?

  • it will compile and nothing will be printed when it is executed.
  • It will compile, but not link.
  • the compiler will generate an error.
  • the compiler will generate a warning.
Show Answer Report

34. void display (int x) { if (x ! = 0) { display (x/16); putchar ("0123456789ABCDEF" [x % 16]); } else putchar ('\n'); } What will be output if the above function is called with x = 1234?

  • 1234
  • 4321
  • 4D2
  • It will not compile
Show Answer Report

35. int i =3, a=1, b=1; void func( ) { int a =0; static int b = 0; a++; b++; } int main ( ) { for ( i = 0, i < 5; i++) { func ( ) ; a++; b++; } printf ("a=%d b =%d\n", a, b); What will be printed from the sample code above ?

  • a=0 b=6
  • a=5=5
  • a=5 b=6
  • a=6 b=6
Show Answer Report

36. long factorial (long  x) { ???? return x * factorial (x-1); } What would you replace the ???? with, to make the function shown above, return the correct answer ?

  • if (x ==0) return 0;
  • if (x==0) return 1;
  • if (x<=1)return 1;
  • return 1;
Show Answer Report

37. if (x ? y : z) do something ( ); Refering to the sample above, which statement correctly identifies when y is evaluated ?

  • y is evaluated only when x = = 1
  • y is evaluated only when x >=1.
  • y is evaluated only when x!=0
  • y is evaluated only when x==0.
Show Answer Report

38. const int var1 = 1; static int var2 = 2; void func ( ) { int var 3 = 3; static int var 4 = 4; } Which of the above variables exist after the function returns and cannot be accessed fromanother file ?

  • var 2 only
  • var4 only
  • var 2 and var 4 only
  • var 2, var3, and var4 only
Show Answer Report

39. void func (int x) { if (x &gt; 0) func (--x); printf (&quot;%d, &quot;, x); } int main ( ) { func (5); return 0; } what will the above sample code produce when executed ?

  • 0, 1, 2, 3, 4, 5
  • 0, 0, 1, 2, 3, 4
  • 4, 3, 2, 1, 0
  • 5, 4, 3, 2, 1, 0
Show Answer Report

40. # include &lt;stdio.h&gt; void show ( ) { printf ( (&quot;Water\n&quot;); } /* main. c */ #include &lt;stdio.h&gt; static void show ( ) { printf (&quot;Drink\n&quot;); int main ( ) { show ( ); return 0; } Referring to the program given by the 2 source files defined in the code above, what will happen when you try to build and run the program?

  • it will print Water
  • It will print Drink.
  • It will print:
  • Drink water
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test