C language MCQs - letsbug
MCQs On C Language | Arrays, Loops, I/O and more
1. Which of the following is not a valid variable name declaration?
- Int_a3;
- int a_3;
- int 3_a;
- int_3a
Answer: 3 : int 3_a;
2. All keywords in C are in ________ .
- Lowercase letters
- Uppercase letters
- Camelcase letters
- None of the above.
Answer: 1 : Lowercase letters
3. The format identifier "%i" is also used for _________ data type.
- char
- int
- float
- double
Answer: 2 : int.
4. Which of the following is a User-defined data type?
- typedef int Boolean;
- typedef enum {Mon, Tue, Wed, Thu, Fri} Wordays;
- struct {char name[10], int age}
- all of the mentioned
Answer: 4 : all of the mentioned
5. What is the precedence of arithmetic operators ( from highest to lowest) ?
- %, * , / , +, -
- %, +, /, *, -
- +, -, %, *, /
- %, +, -, *, /
Answer: 1 : %, *, /, +, -
6. putchar(c) function /macro always outputs character c to the ________ .
- screen
- standard output
- depends on the compiler
- depends on the standard
Answer: 2 : standard output
7. What is the Properties of first argument of a printf() functions?
- It is defined by user.
- It keeps the records of the types of arguments that will follow.
- There may no be first argument.
- None of the above mentioned.
Answer: 2 : It keeps the records of the types of arguments that will follow.
8. What is the purpose of sprintf?
- It prints the data into stdout.
- It writes the formatted data into a string.
- It writes the formatted data into a file.
- None of the above.
Answer: 2 : It writes the formatted data into a string.
9. The syntax to print a % using printf statement can by done by ________.
- %
- \%
- "%"
- %%
Answer: 4 : %%
10. Which among the following is the odd one out?
- printf
- fprintf
- putchar
- scanf
Answer: 4 : scanf
11. If c is a variable initialised to 1, how many times will the following loop be executed?
while (c > 0 && (c, 60))
{
loop body
c ++;
}
- 60
- 59
- 61
- None of these
Answer: 2 : 59
12. A "switch" statement is used to
- Switch between functions in a program
- Switch from one variable to another variable
- To choose from multiple possibilities which may arise due to different values of a single variable.
- All of the above
Answer: 3 : To choose from multiple possibilities which may arise due to different values of a single variable.
13. choose the correct statement.
- Use of goto enhances the logical clarity of the code.
- Use of goto makes the debugging task easier.
- Use of goto when you want to jump out of a nested loop.
- Never use goto statement.
Answer: 3 : Use of goto when you want to jump out of a nested loop.
14. In a for loop, if the condition is missing then,
- It is assumed to be present and taken to be false
- it is assumed to be present and taken to be true.
- it results in a syntax error.
- execution will be terminated abruptly
Answer: 2 : It is assumed to be present and taken to be true.
15. Which of the following comments about a for loop are correct?
- Index value is retained outside the loop and can be changed from within the loop
- Body of the loop can by empty
- goto can be used to jump out of loop.
- All of the above.
Answer: 4 : All of the above.
16. What is right way of initialize array?
- int num[6] = {2,4,12,5,45, 5};
- int n{6} = {2, 4, 12};
- int n{} = {2, 4, 12, 5, 45, 5};
- int n(6) = {2, 4, 12, 5, 45, 5};
Answer: 1 : int num[6] = {2, 4, 12, 5, 45, 5}
17. An array element are always stored in ________ memory locations.
- Sequential
- Random
- Sequential And Random
- None of the above
Answer: 1 : Sequential
18. What is the maximum number of dimensions an array in C may have?
- Two
- Eight
- Sixteen
- Theoretically no limit. The only practical limit are memory size and compilers.
Answer: 4 : Theoretically no limit. The only practical limit are memory size and compilers.
19. What will be the address of the arr[2][3] if arr a 2D long array of 4 rows and 5 columns and starting address of the is 2000?
- 2048
- 2056
- 2052
- 2042
Answer: 3 : 2052.
20. Size of the array need not be specified, when
- Initialization is a part of definition.
- It is a formal parameter
- It is a declaration
- All of the above
Comments
Post a Comment