wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz - Functions in C

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.
Which of the following is not a library function but can be a user defined function?
a)
cos()
b)
sqrt()
c)
pow()
d)
add()
2.
We use fucntions to reuse block of code. How many times, can you call a function?
a)
only one time
b)
2 times
c)
Maximum of 10 times
d)
Any number of times
3.
The prototype of main() is declared in the compiler. What type of fuction is main()?
a)
library
b)
undefined
c)
User-Defined
d)
compiler defined
4.
What vlaue is stored in x? X = scanf("%d %d", &a, &b);
a)
1
b)
2
c)
3
d)
No value assigned
5.
Which character is used separate the parameters list in a function definition?
a)
: (colon)
b)
;(semicolon)
c)
,(comma)
d)
.(dot)
6.
Which of the following is a correct format for declaration of function?
a)
return-type function-name(argument type);
b)
return-type function-name(argument type){}
c)
return-type (argument type)function-name;
d)
argument type function-name(return-type);
7.
How many values can a C Function return at a time?
a)
Only one value
b)
maximum 2 values
c)
maximum 3 values
d)
maximum 8 values
8.
Which of the following is one of the advantages of using Functions in the program?
a)
returning
b)
re-usability
c)
recording
d)
recovery
9.
Which library function is used to find the square root of a number?
a)
squareroot()
b)
SQT()
c)
sqr()
d)
sqrt()
10.
Which of the following library function can be used to evaluate a*a*a?
a)
cube(a)
b)
power(a,3)
c)
Mul(a,3)
d)
pow(a,3)
11.

What is the output of this C code?

void foo();

void main()

{

void f();

f();

}

void foo()

{

printf("2 ");

}

void f()

{

printf("1 ");

foo();

}

a)
Compile Time Error
b)
1 2
c)
2 1
d)
Infinite Loop
12.

What is the output of this C code? int main()

{

int x = 5;

int f();

x = f();

printf("%d", x);

}

int f()

{

int x=10;

return 15;

}

a)
15
b)
5
c)
10
d)
0
13.
The parameters used in a function definition are also called as __________
a)
Actual Arguments
b)
Formal Arguments
c)
Simple Arguments
d)
Simple Parameters
14.
The arguments used in a function call are also called as __________
a)
Actual Arguments
b)
Formal Arguments
c)
Simple Arguments
d)
Simple Parameters
15.

What will be the data type returned for the following function? int func()

{

return (double)(char)5.0;

}

a)
double
b)
char
c)
int
d)
Multiple Type casting is not allowed
16.

What will be the output?

#include<stdio.h>

float circle(int);

void main()

{

float area = 0 ;

int radius = 1 ;

area = circle ( radius ) ;

printf ( "\n%f", area ) ;

}

float circle ( int r )

{

float a ;

a = 3.14 * r * r ;

return ( a ) ;

}

a)
6.28
b)
3.14
c)
3
d)
2.14
17.

What will be the output?

#include<stdio.h>

int junk(int,int);

void main()

{

int i = 5, j = 2 ;

I = junk ( i, j ) ;

printf ( "\n%d %d", i, j ) ;

}

int junk ( int i, int j )

{

i *= i ;

j *= j ;

return i;

}

a)
5,2
b)
25,4
c)
25,2
d)
2,5
18.

What is the scope of the variable z?

void myfunc()

{

int z;

z+= 7;

}

a)
External Variable
b)
Static Variable
c)
Local Variable
d)
Global Variable
19.

Find the error in the following code

#include <stdio.h>

#define PI 3.14;

int main()

{

printf("%f", PI);

return 10;

}

a)
int main()
b)
return 10;
c)
printf("%f", PI);
d)
#define PI 3.14;
20.
Which function definition will run correctly?
a)
int sum(int a, int b) return (a + b);
b)
int sum(int a,int b) {return (a + b);}
c)
int sum(a, b) return (a + b);
d)
int sum(&a, &b) return (a + b);
21.

What is the output of this C code?

void main()

{

m();

}

void m()

{

printf("hi");

m();

}

a)
Infinite hi
b)
hi
c)
Compile Time Error
d)
Linking Error
22.

What is the output of this C code?

void main()

{

static int x = 3;

x++;

if (x <= 5)

{

printf("hi");

main();

}

}

a)
Infinite hi
b)
run time error
c)
hi
d)
hi hi
23.
Which function is used to find the length of a string?
a)
strln()
b)
strlen()
c)
strlength()
d)
strlnt()
24.
Which function is used to reverse the given string?
a)
strrev()
b)
strev()
c)
streverse()
d)
strreverse()
25.

What will be the value of x in the following code?

char str1[]="YES", str2[]="yes";

int x = 0;

x= strcmp(str1, str2));

a)
Garbage value
b)
Positive number
c)
0
d)
Negative number
26.

What will be the value of x in the following code?

char str1[]="yes", str2[]="yeb";

int x = 0;

x= strcmp(str1, str2));

a)
Garbage value
b)
Positive number
c)
0
d)
Negative number
27.

What is the output of the following?

char a[]=”Hello”, char b[]=”BETA”;

strcpy(a, b);

printf("%s %s", a, b);

a)
BETA, Hello
b)
Hello, BETA
c)
Hello, Hello
d)
BETA, BETA
28.

What is the output of the following?

char a[]=”Hello”,

char b[]=”BETA”;

strcat(a, b);

printf("%s %s", a, b);

a)
HelloBETA, BETA
b)
Hello, BETAHello
c)
BETAHello, Hello
d)
Hello, HelloBETA
29.

What is the output of the following? char str1[]="Myworld";

char str2[]="wor";

char *x;

x = strstr(str1, str2);

printf("%s", x);

a)
Myworldwor
b)
Myworld
c)
world
d)
wor
30.

C language has many inbuilt functions. Which of the following is not a library function?

a)

cos()

b)

sqrt()

c)

pow()

d)

add()