C Functions Questions and Answers
Practice ModeShowing 10 of 151 questions
Q31
Which of the following would compute the square of x in C?
Answer: Option B
Q32
All Standard C library <math.h> functions return data type ?
Answer: Option C
Q33
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 ?
Answer: Option A
Q34
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?
Answer: Option C
Q35
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 ?
Answer: Option D
Q36
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 ?
Answer: Option C
Q37
if (x ? y : z) do something ( );
Refering to the sample above, which statement correctly identifies when y is evaluated ?
Answer: Option C
Q38
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 ?
Answer: Option C
Q39
void func (int x)
{
if (x > 0) func (--x);
printf ("%d, ", x);
}
int main ( )
{
func (5);
return 0;
}
what will the above sample code produce when executed ?
Answer: Option B
Q40
# include <stdio.h>
void show ( )
{
printf ( ("Water\n");
}
/* main. c */
#include <stdio.h>
static void show ( )
{
printf ("Drink\n");
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?
Answer: Option B