MCQ for C prgramming

MCQ
1. Which of the following special symbol allowed in a variable name?
A.
* (asterisk)
B.
| (pipeline)
- (hyphen)
_ (underscore)

2. How would you round off a value from 1.92 to 2.0?
A.
ceil(1.92)
B.
floor(1.92)
C.
roundup(1.92)
D.
roundto(1.92)

3. Which of the following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 - 1
A.
* / % + - =
B.
= * / % + -
C.
/ * % - + =
D.
* % / - + =

4. When we mention the prototype of a function?
A.
Defining
B.
Declaring
C.
Prototyping
D.
Calling

5. Which of the following is the correct usage of conditional operators used in C?
A.
a>b ? c=30 : c=40;
B.
a>b ? c=30;
C.
max = a>b ? a>c?a:c:b>c?b:c
D.
return (a>b)?(a:b)

6. Which of the following are unary operators in C?

1
!


2
sizeof


3
~


4
&&

A.
1, 2
B.
1, 3
C.
2, 4
D.
1, 2, 3

7. How many times "WELCOME" is get printed?
#include<stdio.h>
int main()
{
    int x;
    for(x=-1; x<=10; x++)
    {
        if(x < 5)
            continue;
        else
            break;
        printf("WELCOME");
    }
    return 0;
}
A.
Infinite times
B.
11 times
C.
0 times
D.
10 times
8. Which of the following cannot be checked in a switch-case statement?
A.
Character
B.
Integer
C.
Float
D.
enum

9. In C, if you pass an array as an argument to a function, what actually gets passed?
A.
Value of elements in array
B.
First element of the array
C.
Base address of the array
D.
Address of the last element of array

10. Which bitwise operator is suitable for turning off a particular bit in a number?
A.
&& operator
B.
& operator
C.
|| operator
D.
! operator

11. Which bitwise operator is suitable for turning on a particular bit in a number?
A.
&& operator
B.
& operator
C.
|| operator
D.
| operator

12. Which bitwise operator is suitable for checking whether a particular bit is on or off?
A.
&& operator
B.
& operator
C.
|| operator
D.
! operator

13. The keyword used to transfer control from a function back to the calling function is
A.
switch
B.
goto
C.
go back
D.
return

14. Which of the following is not a valid variable name declaration?
A. int __a3;
B. int __3a;
C. int __A3;
D. None of the mentioned

15. All keywords in C are in
A.  LowerCase letters
B.  UpperCase letters
C.  CamelCase letters
D.  None of the mentioned

16. What is the size of an int data type?
A. 4 Bytes
B. 8 Bytes
C. Depends on the system/compiler
D. Cannot be determined

 17. The character used to terminate a string in c is:
A. ' \n'
B. ' \0'
C. ' \a'
D.  none of these

Comments

Popular posts from this blog