C/C MCQ Quiz Hub

C Multiple Choice Questions C Functions Set 1

Choose a topic to test your knowledge and improve your C/C skills

What is the output of this C code? int main() { void foo(), f(); f(); } void foo() { printf("2 "); } void f() { printf("1 "); foo(); }





✅ Correct Answer: 2

What is the output of this C code? int main() { void foo(); void f() { foo(); } f(); } void foo() { printf("2 "); }





✅ Correct Answer: 4

What is the output of this C code? void foo(); int main() { void foo(); foo(); return 0; } void foo() { printf("2 "); }





✅ Correct Answer: 2

What is the output of this C code? void foo(); int main() { void foo(int); foo(1); return 0; } void foo(int i) { printf("2 "); }





✅ Correct Answer: 1

What is the output of this C code? void m() { printf("hi"); } void main() { m(); }





✅ Correct Answer: 1

What is the output of this C code? void m() { printf("hi"); } void main() { m(); }





✅ Correct Answer: 1

What is the output of this C code? void m(); void n() { m(); } void main() { void m() { printf("hi"); } }





✅ Correct Answer: 2

What is the output of this C code? void main() { m(); void m() { printf("hi"); } }





✅ Correct Answer: 2

What is the output of this C code? void main() { m(); } void m() { printf("hi"); m(); }





✅ Correct Answer: 3

What is the output of this C code? void main() { static int x = 3; x++; if (x <= 5) { printf("hi"); main(); } }





✅ Correct Answer: 4

Which of the following function declaration is illegal?





✅ Correct Answer: 4

Which function definition will run correctly?





✅ Correct Answer: 2

Can we use a function as a parameter of another function? [ Eg: void wow(int func()) ]





✅ Correct Answer: 3

The value obtained in the function is given back to main by using ________ keyword?





✅ Correct Answer: 1

What is the return-type of the function sqrt()





✅ Correct Answer: 3

Which of the following function declaration is illegal?





✅ Correct Answer: 4

What is the output of this code having void return-type function? void foo() { return 1; } void main() { int x = 0; x = foo(); printf("%d", x); }





✅ Correct Answer: 4

What will be the data type returned for the following function? int func() { return (double)(char)5.0; }





✅ Correct Answer: 2

What is the problem in the following declarations? int func(int); double func(int); int func(float);





✅ Correct Answer: 4

The output of the code below is void main() { int k = m(); printf("%d", k); } void m() { printf("hello"); }





✅ Correct Answer: 1

The output of the code below is int *m() { int *p = 5; return p; } void main() { int *k = m(); printf("%d", k); }





✅ Correct Answer: 4

The output of the code below is int *m(); void main() { int *k = m(); printf("hello "); printf("%d", k[0]); } int *m() { int a[2] = {5, 8}; return a; }





✅ Correct Answer: 3

The output of the code below is int *m(); void main() { int k = m(); printf("%d", k); } int *m() { int a[2] = {5, 8}; return a; }





✅ Correct Answer: 4

The output of the code below is void m(int k) { printf("hi"); } void m(double k) { printf("hello"); } void main() { m(3); }





✅ Correct Answer: 3

What is the default return type if it is not specified in function definition?





✅ Correct Answer: 2

What is the output of this C code? int foo(); int main() { int i = foo(); } foo() { printf("2 "); return 2; }





✅ Correct Answer: 1

What is the output of this C code? double foo(); int main() { foo(); return 0; } foo() { printf("2 "); return 2; }





✅ Correct Answer: 2

functions can return structure in c?





✅ Correct Answer: 1

functions can return enumeration constants in c?





✅ Correct Answer: 1

What is the output of this C code? void main() { m(); printf("%d", x); } int x; void m() { x = 4; }





✅ Correct Answer: 2

What is the output of this C code? int x; void main() { printf("%d", x); }





✅ Correct Answer: 3

What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { x = 4; } printf("%d", x); }





✅ Correct Answer: 4

What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { int x = 4; } printf("%d", x); }





✅ Correct Answer: 1

Functions in C are ALWAYS:





✅ Correct Answer: 2

Which of the following are an external variable? int func (int a) { int b; return b; } int main() { int c; func (c); } int d;





✅ Correct Answer: 4

What will be the output? int main() { printf("%d", d++); } int d = 10;





✅ Correct Answer: 4

What will be the output? double var = 8; int main() { int var = 5; printf("%d", var); }





✅ Correct Answer: 1

What is the output of this C code? double i; int main() { printf("%g ",i); return 0; }





✅ Correct Answer: 2

Which part of the program address space is p stored in the code given below? int *p; int main() { int i = 0; p = &i; return 0; }





✅ Correct Answer: 3

Can variable i be accessed by functions in another source file? int i; int main() { printf("%d ", i); }





✅ Correct Answer: 1

Property of external variable to be accessed by any source file is called by C90 standard as:





✅ Correct Answer: 1

What is the output of this C code? int *i; int main() { if (i == NULL) printf("true "); return 0; }





✅ Correct Answer: 1

What is the output of this C code? int *i; int main() { if (i == 0) printf("true "); return 0; }





✅ Correct Answer: 2

What is the output of this C code? static int x = 5; void main() { x = 9; { int x = 4; } printf("%d", x); }





✅ Correct Answer: 1

What is the output of this C code? void main() { m(); m(); } void m() { static int x = 5; x++; printf("%d", x); }





✅ Correct Answer: 1

What is the output of this C code? void main() { static int x; printf("x is %d", x); }





✅ Correct Answer: 1

What is the output of this C code? static int x; void main() { int x; printf("x is %d", x);





✅ Correct Answer: 2

What is the output of this C code? void main() { static double x; int x; printf("x is %d", x); }





✅ Correct Answer: 3

What is the output of this C code? void main() { static int x; if (x++ < 2) main(); }





✅ Correct Answer: 4

Which of following is not accepted in C?





✅ Correct Answer: 3

Which of the following cannot be static in C?





✅ Correct Answer: 4

The scope of an automatic variable is:





✅ Correct Answer: 4

Automatic variables are allocated space in the form of a:





✅ Correct Answer: 1

Which of the following is a storage specifier?





✅ Correct Answer: 3

Default storage class if not any is specified for a local variable, is auto:





✅ Correct Answer: 1

Automatic variables are stored in:





✅ Correct Answer: 1

What linkage does automatic variables have?





✅ Correct Answer: 3

What is the output of this C code? int main() { auto i = 10; const auto int *p = &i; printf("%d ", i); }





✅ Correct Answer: 1