C Programming MCQ on Functions

The execution of program begins from which function a C program?
a) main() function
b) start() function
c) void
d) All of above


Answer:a
Explanation: main() function is the starting point of execution of every C program.

Which function is used to read a single character from stdin in C programming language?
a) getc()
b) getch()
c) getchar()
d) All of the above


Answer:d

Which function is used to calculate the power x raise to y (xy) in C?
a) power()
b) pow()
c) degree()
d) None of the above


Answer:b

Which function is used to calculate the natural log of x in C programming language?
a) log()
b) logarithm()
c) logx()
d) All of above


Answer:a

Which function is used to calculate e raise to x (ex) in C?
a) ex()
b) expo()
c) exp()
d) exponential()


Answer:c

Which function is used to get the absolute of value of number in C?
a) abs()
b) absolute()
c) abval()
d) None of the above


Answer:a
Explanation: abs() returns the absolute value of a number passed to it. For example, abs(5.60) returns 5.

Which function is used to calculate the sine of given value in C?
a) sine()
b) sin()
c) naturalsin()
d) None if the above


Answer:b

Which function is used to calculate the square root of a number in C programming language?
a) sqrt()
b) sqroot()
c) sqr()
d) All of above()


Answer:a
Explanation: sqrt() function returns the square root of value passed to it as argument. For example, sqrt(4) returns 2 because square root of 4 is 2.

Which function is uses to calculate the cos of given value in C?
a) cos()
b) cosine()
c) sec()
d) None of the above()


Answer:a

Which function is used to outputs a string to stdout with newline character implicitly attached at the end?
a) printf()
b) scanf()
c) puts()
d) None of above


Answer:c

Which function is used to write formatted output to stdout in C?
a) puts()
b) printf()
c) sprintf()
d) All of above


Answer:b

Which function converts a string to an integer in C?
a) atoi()
b) stringtoint()
c) convert()
d) All of above


Answer:a

Which function converts string to floating point number in C?
a) atoi()
b) atofp()
c) atod()
d) atof()


Answer:d

Which function converts string to long in C?
a) atol()
b) atoi()
c) atofp()
d) None of above


Answer:a

Which function is used to get integer corresponding to keystroke entered in C?
a) getKey()
b) kbhit()
c) kval()
d) ikey()


Answer:b

How many values can a function return in C?
a) 1
b) 2
c) 3
d) Multiple


Answer:a
Explanation: A function in C programing language can return only one value.

Which keyword is used to terminate the execution of a function in C?
a) stop
b) exit
c) return
d) terminate


Answer:c
Explanation: return keyword is used to return a value to calling function (usually main() function) and it terminates the execution.

What is the type of function call if changes made to formal paramters does not affect the actual parameters?
a) call by refernce
b) call by value
c) Both a and b
d) None of above


Answer:b

What is the name of process in which the function calls itself repeatedly?
a) continuation
b) looping
c) recursion
d) All of above


Answer:c

If the identifiers are defined within a function or block what type of scope do they have?
a) Local scope
b) Global scope
c) Package scope
d) All of above


Answer:a

How to declare a function that does not return a value in C?
a) void noValue()
b) int noValue()
c) float noValue()
d) char noValue()


Answer:a

Which of the following are valid paramter passing modes for functions in C?
a) call variables and call by reference
b) call by value and call by variables
c) call by value and call by reference
d) All of above


Answer: