Skip to content
ExamHope Logo

examhope

Primary Menu
  • Digital Logic
    • Arithmetic Operations
    • Asynchronous/Ripple Counters
    • Basic Gates
    • Boolean Algebraic Theorems
    • Codes
  • Data Structures
    • Binary Heaps
    • Binary Search
    • Binary Search Trees
    • Binary Tree
    • Binary Tree Sort
    • Bipartite Graphs
    • Complete Graph
  • Theory of Computation
    • Finite Automata
    • Finite Automaton First Example
  • Current Affairs
    • Sports News
    • Tech News
    • Bollywood News
    • Daily News
  • Database
  • Computer Network
  • Computer Organization and Architecture
  • C Language
  • Operating Systems
  • Software Engineering
  • Theory of Computation
  • About us
  • Contact Us
  • Privacy Policy
  • DMCA Policy
  • Terms and Conditions
  • Home
  • IT
  • Defining and Calling Functions MCQs in C Language
  • IT
  • C Language
  • Defining and Calling Functions

Defining and Calling Functions MCQs in C Language

examhopeinfo@gmail.com October 24, 2025 8 minutes read
Defining and Calling Functions MCQs in C Language

Defining and Calling Functions MCQs in C Language

Defining and Calling Functions MCQs in C Language


1.

What is the output?

#include <stdio.h>
void fun() {
    printf("Hello");
}
int main() {
    fun();
    return 0;
}

A) Hello
B) fun
C) main
D) Compiler error

โœ… Answer: A
Explanation:
Function fun() is defined and called inside main() โ†’ prints โ€œHelloโ€.


2.

Which of the following is correct for function declaration?

A) int fun();
B) fun int();
C) void int fun();
D) int() fun;

โœ… Answer: A
Explanation:
C function declaration syntax โ†’ return_type function_name(parameters);.


3.

Output:

#include <stdio.h>
int add(int a, int b) {
    return a+b;
}
int main() {
    printf("%d", add(2,3));
}

A) 23
B) 5
C) 6
D) 0

โœ… Answer: B
Explanation:
add(2,3) returns 5 โ†’ printed by printf.


4.

Which of the following is function definition with no return value?

A) int fun() {}
B) void fun() {}
C) float fun() {}
D) char fun() {}

โœ… Answer: B
Explanation:
void โ†’ indicates no value returned.


5.

What is output?

#include <stdio.h>
void display(int x) {
    x += 5;
    printf("%d", x);
}
int main() {
    int a=10;
    display(a);
    printf("%d", a);
}

A) 1510
B) 1015
C) 15 10
D) 10 15

โœ… Answer: C
Explanation:
display receives a copy of a โ†’ increments inside function โ†’ prints 15 โ†’ a in main unchanged โ†’ prints 10.


6.

Which is correct call to a function int sum(int, int);?

A) sum(2,3);
B) int sum(2,3);
C) int sum = sum(2,3);
D) sum(int 2, int 3);

โœ… Answer: A
Explanation:
Function is called with actual parameters โ†’ sum(2,3).


7.

What is the output?

#include <stdio.h>
int fun() {
    return 5;
}
int main() {
    printf("%d", fun());
}

A) fun
B) 5
C) main
D) Compiler error

โœ… Answer: B
Explanation:
fun() returns 5 โ†’ printed by printf.


8.

Which of the following is function prototype?

A) int sum();
B) void sum(int,int);
C) Both A and B
D) int sum(int a,int b) { }

โœ… Answer: C
Explanation:
Both declarations are valid prototypes; definition is different.


9.

Output:

#include <stdio.h>
void swap(int a, int b) {
    int t = a;
    a = b;
    b = t;
}
int main() {
    int x=2,y=3;
    swap(x,y);
    printf("%d %d", x,y);
}

A) 3 2
B) 2 3
C) 5 5
D) 0 0

โœ… Answer: B
Explanation:
C passes arguments by value โ†’ original x,y unchanged.


10.

Which is correct function returning float?

A) float fun();
B) void fun();
C) int fun();
D) char fun();

โœ… Answer: A
Explanation:
float โ†’ specifies return type of function.


11.

Output:

#include <stdio.h>
void fun(int a, int b) {
    printf("%d", a*b);
}
int main() {
    fun(2,3);
}

A) 5
B) 6
C) 23
D) 0

โœ… Answer: B
Explanation:
2*3=6 โ†’ printed.


12.

Which of the following is invalid function call?

A) fun();
B) fun(5);
C) fun(1,2);
D) fun(1,2,3);

โœ… Answer: D
Explanation:
Function expects 2 parameters โ†’ passing 3 causes error.


13.

Output:

#include <stdio.h>
int factorial(int n) {
    if(n==0) return 1;
    return n*factorial(n-1);
}
int main() {
    printf("%d", factorial(3));
}

A) 6
B) 3
C) 9
D) 0

โœ… Answer: A
Explanation:
3! = 321 = 6 โ†’ printed.


14.

Which statement is TRUE about recursion?

A) Recursion cannot have base case
B) Base case is optional
C) Recursion must have a base case
D) Recursion never returns value

โœ… Answer: C
Explanation:
Base case is needed to terminate recursion, otherwise infinite recursion.


15.

Output:

#include <stdio.h>
void add(int *a, int *b) {
    *a = *a + *b;
}
int main() {
    int x=2,y=3;
    add(&x,&y);
    printf("%d", x);
}

A) 2
B) 3
C) 5
D) 6

โœ… Answer: C
Explanation:
Passing by pointer โ†’ modifies original x โ†’ 2+3=5 โ†’ prints 5.


16.

Which of the following is valid recursion?

A) void fun() { fun(); }
B) int fun() { return fun(); }
C) int fun(int n) { if(n==0) return 0; return fun(n-1); }
D) All of the above

โœ… Answer: D
Explanation:
All are syntactically valid; only base case prevents infinite recursion.


17.

Output:

#include <stdio.h>
int sum(int a,int b) {
    return a+b;
}
int main() {
    printf("%d", sum(2+3,4+5));
}

A) 14
B) 11
C) 12
D) 9

โœ… Answer: A
Explanation:
sum(5,9) โ†’ returns 14 โ†’ printed.


18.

Which of the following is TRUE for function declaration?

A) Only return type mandatory
B) Parameter names mandatory
C) Parameter types mandatory
D) None

โœ… Answer: C
Explanation:
Parameter types mandatory; names optional in prototype.


19.

Output:

#include <stdio.h>
void display() {
    printf("Hi ");
}
int main() {
    display();
    display();
}

A) Hi
B) Hi Hi
C) HiHi
D) Compiler error

โœ… Answer: C
Explanation:
display() prints โ€œHiโ€ twice โ†’ output concatenated โ†’ HiHi.


20.

Output:

#include <stdio.h>
int sum(int a,int b) {
    return a+b;
}
int main() {
    int (*ptr)(int,int) = sum;
    printf("%d", ptr(2,3));
}

A) Compiler error
B) 23
C) 5
D) 6

โœ… Answer: C
Explanation:
Function pointer ptr calls sum(2,3) โ†’ 5 โ†’ printed.

21.

Output:

#include <stdio.h>
void fun(int a=5) {
    printf("%d", a);
}
int main() {
    fun();
}

A) 0
B) 5
C) Compiler error
D) Nothing

โœ… Answer: C
Explanation:
C does not support default arguments (C++ only) โ†’ compiler error.


22.

Output:

#include <stdio.h>
int sum(int a, int b) {
    return a+b;
}
int main() {
    int x=2,y=3;
    printf("%d", sum(x,y)+sum(y,x));
}

A) 10
B) 12
C) 5
D) 6

โœ… Answer: A
Explanation:
sum(2,3)=5, sum(3,2)=5 โ†’ 5+5=10 โ†’ printed.


23.

Which statement is TRUE about call by value?

A) Original variable is changed
B) Function receives a copy of variable
C) Pointers not allowed
D) Always faster

โœ… Answer: B
Explanation:
Call by value passes a copy โ†’ original variable unaffected.


24.

Output:

#include <stdio.h>
void increment(int *p) {
    (*p)++;
}
int main() {
    int x=5;
    increment(&x);
    printf("%d", x);
}

A) 5
B) 6
C) Compiler error
D) 0

โœ… Answer: B
Explanation:
Passing pointer โ†’ modifies original โ†’ x=6.


25.

Which is correct recursive factorial function?

A) int fact(int n) { return n*fact(n-1); }
B) int fact(int n) { if(n==0) return 1; return n*fact(n-1); }
C) int fact(int n) { return 1; }
D) void fact(int n) { return n*fact(n-1); }

โœ… Answer: B
Explanation:
Base case n==0 ensures termination โ†’ returns factorial correctly.


26.

Output:

#include <stdio.h>
int fun() {
    int x=5;
    return x++;
}
int main() {
    printf("%d", fun());
}

A) 5
B) 6
C) Compiler error
D) 0

โœ… Answer: A
Explanation:
Post-increment returns value before increment โ†’ prints 5.


27.

Output:

#include <stdio.h>
void swap(int *a,int *b) {
    int t=*a; *a=*b; *b=t;
}
int main() {
    int x=2,y=3;
    swap(&x,&y);
    printf("%d %d", x,y);
}

A) 2 3
B) 3 2
C) 5 5
D) Compiler error

โœ… Answer: B
Explanation:
Passing pointers โ†’ original variables swapped โ†’ 3 2.


28.

Which of the following cannot be passed by reference in C?

A) int
B) float
C) array
D) int literal

โœ… Answer: D
Explanation:
Cannot pass literal addresses โ†’ only variables or arrays.


29.

Output:

#include <stdio.h>
int add(int a,int b) {
    int c = a+b;
}
int main() {
    printf("%d", add(2,3));
}

A) 5
B) 0
C) Garbage
D) Compiler error

โœ… Answer: C
Explanation:
add() has no return โ†’ behavior undefined โ†’ prints garbage.


30.

Which is TRUE about function pointers?

A) Can point to functions
B) Can store return value
C) Cannot be passed as arguments
D) Always void type

โœ… Answer: A
Explanation:
Function pointers store function addresses โ†’ callable via pointer.


31.

Output:

#include <stdio.h>
int sum(int a,int b) {
    return a+b;
}
int main() {
    int (*ptr)(int,int)=sum;
    printf("%d", ptr(4,5));
}

A) Compiler error
B) 45
C) 9
D) 10

โœ… Answer: C
Explanation:
sum(4,5)=9 โ†’ function pointer ptr calls sum โ†’ prints 9.


32.

Output:

#include <stdio.h>
void fun() {
    printf("Hi");
}
int main() {
    void (*fp)()=fun;
    fp();
}

A) Hi
B) fp
C) Compiler error
D) Nothing

โœ… Answer: A
Explanation:
Function pointer fp calls fun() โ†’ prints Hi.


33.

Which of the following is invalid?

A) int sum(int,int);
B) int sum(int a,int b);
C) int sum(a,b); int a,b;
D) int sum(int a=5,int b=5);

โœ… Answer: D
Explanation:
C does not support default arguments (C++ only).


34.

Output:

#include <stdio.h>
void fun(int a) {
    printf("%d", a*2);
}
int main() {
    fun(3+2);
}

A) 5
B) 10
C) 6
D) 3

โœ… Answer: B
Explanation:
fun(3+2) โ†’ fun(5) โ†’ 5*2=10 โ†’ printed.


35.

Output:

#include <stdio.h>
void fun(int n) {
    if(n==0) return;
    printf("%d", n);
    fun(n-1);
}
int main() {
    fun(3);
}

A) 123
B) 321
C) 3
D) Compiler error

โœ… Answer: B
Explanation:
Recursion โ†’ prints 3,2,1 โ†’ B.


36.

Output:

#include <stdio.h>
void fun(int *x) {
    (*x)++;
}
int main() {
    int a=10;
    fun(&a);
    printf("%d", a);
}

A) 10
B) 11
C) Compiler error
D) 0

โœ… Answer: B
Explanation:
Passing pointer โ†’ increments original variable โ†’ prints 11.


37.

Which is TRUE about recursion?

A) Base case optional
B) Cannot return values
C) Each call has its own stack frame
D) Only one recursion allowed

โœ… Answer: C
Explanation:
Each recursive call stores its parameters and local variables in stack โ†’ own frame.


38.

Output:

#include <stdio.h>
int sum(int a,int b) {
    static int c=0;
    c += a+b;
    return c;
}
int main() {
    printf("%d ", sum(2,3));
    printf("%d", sum(1,1));
}

A) 5 2
B) 5 7
C) 5 6
D) 0 0

โœ… Answer: B
Explanation:
Static variable retains value โ†’ first call: c=5 โ†’ second: c=5+2=7.


39.

Output:

#include <stdio.h>
int fun(int n) {
    if(n==0) return 0;
    return n + fun(n-1);
}
int main() {
    printf("%d", fun(3));
}

A) 6
B) 3
C) 0
D) 9

โœ… Answer: A
Explanation:
3+2+1+0=6 โ†’ printed.


40.

Output:

#include <stdio.h>
void fun(int a,int b) {
    int t=a; a=b; b=t;
}
int main() {
    int x=1,y=2;
    fun(x,y);
    printf("%d %d", x,y);
}

A) 2 1
B) 1 2
C) 3 3
D) Compiler error

โœ… Answer: B
Explanation:
Call by value โ†’ original x,y unchanged โ†’ prints 1 2.

About the Author

examhopeinfo@gmail.com

Administrator

Visit Website View All Posts

Post navigation

Previous: Control Flow MCQs in C Language
Next: Function Prototypes and Parameters(pass by value, pass by reference) MCQs in C Language

Related News

Vivo X200 Price Drop
  • IT
  • Current Affairs
  • Tech News

Vivo X200: เคœเคพเคจเฅ‡ เค•เคฟเคคเคจเฅ€ เค•เคฎ เค•เฅ€เคฎเคค เคชเคฐ เคฎเคฟเคฒ เคฐเคนเคพ เคฏเฅ‡ 9400 เคฎเคฟเคกเคฟเคฏเคพ เคŸเฅ‡เค• เคชเฅเคฐเฅ‹เคธเฅ‡เคธเคฐ เคตเคพเคฒเคพ เคธเฅเคฎเคพเคฐเฅเคŸเคซเฅ‹เคจ

examhopeinfo@gmail.com December 23, 2025 0
Samsung Galaxy S25 Plus
  • IT
  • Current Affairs
  • Tech News

Samsung Galaxy S25 Plus เคชเคฐ เคฎเคฟเคฒ เคฐเคนเฅ€ เคญเคพเคฐเฅ€ เค›เฅ‚เคŸ ,เคœเคพเคจเฅ‡ เคธเฅ‡เคฒ เคชเฅเคฐเคพเค‡เคธ

examhopeinfo@gmail.com December 22, 2025 0
Electricity bill saving Smart Plug
  • IT
  • Current Affairs
  • Tech News

AI เค•เฅ‡ เค‡เคธ เฅ›เคฎเคพเคจเฅ‡ เคฎเฅ‡เค‚ เค•เฅˆเคธเฅ‡ เคฌเคฟเคœเคฒเฅ€ เคฌเคšเคพ เคฐเคนเฅ‡ เคนเฅˆเค‚ เคฏเคน เคธเฅเคฎเคพเคฐเฅเคŸ เคชเฅเคฒเค—?

examhopeinfo@gmail.com December 21, 2025 0

Recent Posts

  • Vivo X200: เคœเคพเคจเฅ‡ เค•เคฟเคคเคจเฅ€ เค•เคฎ เค•เฅ€เคฎเคค เคชเคฐ เคฎเคฟเคฒ เคฐเคนเคพ เคฏเฅ‡ 9400 เคฎเคฟเคกเคฟเคฏเคพ เคŸเฅ‡เค• เคชเฅเคฐเฅ‹เคธเฅ‡เคธเคฐ เคตเคพเคฒเคพ เคธเฅเคฎเคพเคฐเฅเคŸเคซเฅ‹เคจ
  • Samsung Galaxy S25 Plus เคชเคฐ เคฎเคฟเคฒ เคฐเคนเฅ€ เคญเคพเคฐเฅ€ เค›เฅ‚เคŸ ,เคœเคพเคจเฅ‡ เคธเฅ‡เคฒ เคชเฅเคฐเคพเค‡เคธ
  • AI เค•เฅ‡ เค‡เคธ เฅ›เคฎเคพเคจเฅ‡ เคฎเฅ‡เค‚ เค•เฅˆเคธเฅ‡ เคฌเคฟเคœเคฒเฅ€ เคฌเคšเคพ เคฐเคนเฅ‡ เคนเฅˆเค‚ เคฏเคน เคธเฅเคฎเคพเคฐเฅเคŸ เคชเฅเคฒเค—?
  • เค•เฅเคฏเคพ เคนเฅˆ เคฏเคน GhostPairing Scam เค”เคฐ เคฌเคฟเคจเคพ เคชเคพเคธเคตเคฐเฅเคก เค”เคฐ เคธเคฟเคฎ เค•เฅ‡ เค•เฅเคฏเฅ‹เค‚ เคนเฅ‹ เคฐเคนเคพ เคนเฅˆ เคตเฅเคนเคพเคŸเฅเคธเคชเฅเคช เค…เค•เคพเค‰เค‚เคŸ เคนเฅˆเค•
  • Leica เค•เฅˆเคฎเคฐเฅ‡ เค•เฅ‡ เคธเคพเคฅ เคœเคฒเฅเคฆ เคฒเฅ‰เคจเฅเคš เคนเฅ‹ เคธเค•เคคเคพ เคนเฅˆ Xiaomi Ultra 17

At ExamHope, we understand that preparing for exams can be challenging, overwhelming, and sometimes stressful. Thatโ€™s why we are dedicated to providing high-quality educational resources, tips, and guidance to help students and aspirants achieve their goals with confidence. Whether you are preparing for competitive exams, school tests, or professional certifications, ExamHope is here to make your learning journey smarter, easier, and more effective.

Quick links

  • About us
  • Contact Us
  • Privacy Policy
  • Terms and Conditions
  • Disclaimer
  • DMCA Policy

Category

  • Computer Network
  • Computer Organization and Architecture
  • Data Structures
  • C Language
  • Theory of Computation
  • Database

You may have missed

Vivo X200 Price Drop
  • IT
  • Current Affairs
  • Tech News

Vivo X200: เคœเคพเคจเฅ‡ เค•เคฟเคคเคจเฅ€ เค•เคฎ เค•เฅ€เคฎเคค เคชเคฐ เคฎเคฟเคฒ เคฐเคนเคพ เคฏเฅ‡ 9400 เคฎเคฟเคกเคฟเคฏเคพ เคŸเฅ‡เค• เคชเฅเคฐเฅ‹เคธเฅ‡เคธเคฐ เคตเคพเคฒเคพ เคธเฅเคฎเคพเคฐเฅเคŸเคซเฅ‹เคจ

examhopeinfo@gmail.com December 23, 2025 0
Samsung Galaxy S25 Plus
  • IT
  • Current Affairs
  • Tech News

Samsung Galaxy S25 Plus เคชเคฐ เคฎเคฟเคฒ เคฐเคนเฅ€ เคญเคพเคฐเฅ€ เค›เฅ‚เคŸ ,เคœเคพเคจเฅ‡ เคธเฅ‡เคฒ เคชเฅเคฐเคพเค‡เคธ

examhopeinfo@gmail.com December 22, 2025 0
Electricity bill saving Smart Plug
  • IT
  • Current Affairs
  • Tech News

AI เค•เฅ‡ เค‡เคธ เฅ›เคฎเคพเคจเฅ‡ เคฎเฅ‡เค‚ เค•เฅˆเคธเฅ‡ เคฌเคฟเคœเคฒเฅ€ เคฌเคšเคพ เคฐเคนเฅ‡ เคนเฅˆเค‚ เคฏเคน เคธเฅเคฎเคพเคฐเฅเคŸ เคชเฅเคฒเค—?

examhopeinfo@gmail.com December 21, 2025 0
Ghost Pairing Scam on Whatsapp
  • IT
  • Current Affairs
  • Tech News

เค•เฅเคฏเคพ เคนเฅˆ เคฏเคน GhostPairing Scam เค”เคฐ เคฌเคฟเคจเคพ เคชเคพเคธเคตเคฐเฅเคก เค”เคฐ เคธเคฟเคฎ เค•เฅ‡ เค•เฅเคฏเฅ‹เค‚ เคนเฅ‹ เคฐเคนเคพ เคนเฅˆ เคตเฅเคนเคพเคŸเฅเคธเคชเฅเคช เค…เค•เคพเค‰เค‚เคŸ เคนเฅˆเค•

examhopeinfo@gmail.com December 21, 2025 0
Copyright ยฉ All rights reserved for ExamHope. | MoreNews by AF themes.
Go to mobile version