Uploaded by 076bas027.praphul

C mcq control function

advertisement
1 Which of the following prototype declarations is valid ? [d]
(a) int (fun) void;
(b) double fun;
(c) float fun (x, y, n);
(d) void fun (int,int);
2 Which of the following header line is invalid? [b]
(a) float average (float x, float y, float z);
(b) double power (double a, int n – 1)
(c) double minimum (double x, double y);
(d) void sum (int a, int b, int &c)
3 A function to divide two floating point numbers is as follows: [LO 10.3 M]
Int divide (float x, float y)
{
return (x / y);
}
What will be the value of divide(9,2)? [d]
(a) 1.8
(b) 2
(c) 0
(d) 1
4 Which operators are known as Ternary Operator? [b]
A. ::, ?
B. ?, :
C. ?, ;;
D. None of the above
5 What is the work of break keyword? [c]
A. Halt execution of program
B. Restart execution of program
C. Exit from loop or switch statement
D. None of the above
6 What is function? [d]
A. Function is a block of statements that perform some specific task.
B. Function is the fundamental modular unit. A function is usually designed to perform
a specific
task.
C. Function is a block of code that performs a specific task. It has a name and it is
reusable
D. All the above
7 Which one of the following sentences is true ? [b]
A. The body of a while loop is executed at least once.
B. The body of a do ... while loop is executed at least once.
C. The body of a do ... while loop is executed zero or more times.
D. A for loop can never be used in place of a while loop.
8 The Default Parameter Passing Mechanism is called as [a]
A. Call by Value
B. Call by Reference
C. Call by Address
D. Call by Name
9 What will be the output of the following statements ? [a]
int a = 4, b = 7,c;
c = a = = b;
printf("%i",c);
a) 0
b) error
c) 1
d) garbage value
10 What will be the output of the following program ? [a]
#include
void main()
{ int a = 2;
switch(a)
{ case 1:
printf("goodbye"); break;
case 2:
continue;
case 3:
printf("bye");
}
}
a) error
b) goodbye
c) bye
d) byegoodbye
11 What will be the output of the following statements ? [d]
int a=5,b=6,c=9,d; d=(ac?1:2):(c>b?6:8)); printf("%d",d);
a) 1
b) 2
c) 6
d) Error
12 int i = 4;
switch (i)
{
default: ;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
[a]
printf("i = %d\n", i);
What will the output of the sample code above be?
a) i = 5
b) i = 8
c) i = 9
d) i = 10
13 Which keyword can be used for coming out of recursion?
A. break
B. return
C. exit
D. Both (a) and (b)
14 What is the output of this C code? [d]
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
continue;
}
}
(a) 2
(b) 3
(c) 4
(d) 5
15 The keyword break cannot be simply used within:
(a) do_while
(b) if_else
(c) while
(d) for
[b]
[b]
16 Which keyword is used to skip a single iteration of a loop:
[c]
(a) break
(b) return
(c) continue
(d) none of the above
17 In C, parameters are always [c]
A Passed by value
B Passed by reference
C Non-pointer variables are passed by value and pointers are passed by reference
D Passed by value result
18 Choose correct statement/s about Functions in C Language.
[d]
A) A Function is a group of c statements which can be reused any number of times.
B) Every Function has a return type.
C) Every Function may not return a value.
D) All the above.
19 4) A function which calls itself is called a ___ function.
[c]
A) Self Function
B) Auto Function
C) Recursive Function
D) Static Function
20 How many values can a C Function return at a time.?
A) Only One Value
B) Maximum of two values
C) Maximum of three values
D) Maximum of 8 values
[a]
Download