[go: up one dir, main page]

0% found this document useful (0 votes)
256 views4 pages

A. B. C. D.: Module - 4 1

This document contains 10 multiple choice questions about C programming functions. It tests knowledge of function return types, function signatures, order of function calls, external variables, and function declarations. The correct answers are provided for each question.

Uploaded by

Pratik Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
256 views4 pages

A. B. C. D.: Module - 4 1

This document contains 10 multiple choice questions about C programming functions. It tests knowledge of function return types, function signatures, order of function calls, external variables, and function declarations. The correct answers are provided for each question.

Uploaded by

Pratik Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Module -4

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

A. void

B. int

C. double

D. short int
Answer: Option B

2. What is the output of this C code?

int foo();
int main()
{
int i = foo();
}
foo()
{
printf("2 ");
return 2;
}

A. 2

B. Compile time error

C. Depends on the compiler

D. Depends on the standard


Answer: Option A

3. What is the output of this C code?

void main()
{
static int x = 3;
x++;
if (x <= 5)
{
printf("hi");
main();
}
}

A. Run time error

B. hi

C. infinite hi

D. hi hi
Answer: Option D

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

A. int

B. float

C. double

D. Depends on the data type of the parameter

Answer: Option C

5. What is the problem in the following declarations?


int func(int);
double func(int);
int func(float);

A. A function with same name cannot have different signatures

B. A function with same name cannot have different return types

C. A function with same name cannot have different number of parameters

D. All of the mentioned

Answer: Option D

6. Which of the following are an external variable?

int func (int a)


{
int b;
return b;
}
int main()
{
int c;
func (c);
}
int d;

A. a

B. b

C. c

D. d

Answer: Option D

7. How many times is ‘a’ printed when the following C code is executed?
#include<stdio.h>
main()
{
int a;
a=f1(10);
printf("%d",a);
}
f1(int b)
{
if(b==0)
return 0;
else
{
printf("a");
f1(b--);
}
}

a) 9 times
b) 10 times
c) 0 times
d) Infinite number of times

Answer: d
8. In the following 'C' code, in which order the functions would be called ?

a = ( f1(23,14 ) * f2 (12/14)) + f3 () ;
A f1,f2,f3
.
B f3,f2,f1
.
C The order may vary from compiler to compiler
.
D None of these
.

Option: A

9. It is necessary to declare the type of a function in the calling program if the function

A Returns an integer
.
B Returns a non-integer value
.
C Is not defined in the same file
.
D None of these
.

Option: B

10. The declaration

void function1(int)

indicates the function1 is a function which


A. Has no arguments

B. Returns nothing

C. Both (a) and (b)

D. None of these

Option: B

You might also like