60
74k
Chapter:

40+ Introduction to C Language Solved MCQs

in C Language

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Bachelor of Business Administration in Computer Applications (BBA [CA]) .

Chapters

Chapter: Introduction to C Language
1.

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
Answer» D. None of the mentioned
2.

Which of the following is not a valid variable name declaration?

A. int _a3;
B. int a_3;
C. int 3_a;
D. int _3a
Answer» C. int 3_a;
3.

Why do variable names beginning with the underscore is not encouraged?

A. It is not standardized
B. To avoid conflicts since assemblers and loaders use such names
C. To avoid conflicts since library routines use such names
D. To avoid conflicts with environment variables of an operating system
Answer» C. To avoid conflicts since library routines use such names
4.

All keywords in C are in ____________

A. LowerCase letters
B. UpperCase letters
C. CamelCase letters
D. None of the mentioned
Answer» A. LowerCase letters
5.

Variable name resolution (number of significant characters for the uniqueness of variable) depends on ___________

A. Compiler and linker implementations
B. Assemblers and loaders implementations
C. C language
D. None of the mentioned
Answer» A. Compiler and linker implementations
6.

Which of the following is not a valid C variable name?

A. int number;
B. float rate;
C. int variable_count;
D. int $main;
Answer» D. int $main;
7.

Which of the following is true for variable names in C?

A. They can contain alphanumeric characters as well as special characters
B. It is not an error to declare a variable to be one of the keywords(like goto, static)
C. Variable names cannot start with a digit
D. Variable can be of any length
Answer» C. Variable names cannot start with a digit
8.

What is short int in C programming?

A. The basic data type of C
B. Qualifier
C. Short is the qualifier and int is the basic data type
D. All of the mentioned
Answer» C. Short is the qualifier and int is the basic data type
9.

The format identifier ‘%i’ is also used for _____ data type.

A. char
B. int
C. float
D. double
Answer» B. int
10.

Which data type is most suitable for storing a number 65000 in a 32-bit system?

A. signed short
B. unsigned short
C. long
D. int
Answer» B. unsigned short
11.

Which of the following is a User-defined data type?

A. typedef int Boolean;
B. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
C. struct {char name[10], int age};
D. all of the mentioned
Answer» D. all of the mentioned
12.

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
Answer» C. Depends on the system/compiler
13.

enum types are processed by _________

A. Compiler
B. Preprocessor
C. Linker
D. Assembler
Answer» A. Compiler
14.

Which of the following statement is false?

A. Constant variables need not be defined as they are declared and can be defined later
B. Global constant variables are initialized to zero
C. const keyword is used to define constant values
D. You cannot reassign a value to a constant variable
Answer» A. Constant variables need not be defined as they are declared and can be defined later
15.

Which of the following declaration is not supported by C?

A. String str;
B. char *str;
C. float str = 3e2;
D. Both String str; & float str = 3e2;
Answer» A. String str;
16.

Which of the following declaration is illegal?

A. char *str = “string Contents”;
B. char str[] = “string Contents””;
C. char str[20] = “string Contents””;
D. char[] str = “string Contents””;
Answer» D. char[] str = “string Contents””;
17.

Which keyword is used to prevent any changes in the variable within a C program?

A. immutable
B. mutable
C. const
D. volatile
Answer» C. const
18.

Which of the following is not a pointer declaration?

A. char a[10];
B. char a[] = {‘1’, ‘2’, ‘3’, ‘4’};
C. char *str;
D. char a;
Answer» D. char a;
19.

Which of the following statement is false?

A. A variable defined once can be defined again with different scope
B. A single variable cannot be defined with two different types in the same scope
C. A variable must be declared and defined at the same time
D. A variable refers to a location in memory
Answer» C. A variable must be declared and defined at the same time
20.

A variable declared in a function can be used in main().

A. True
B. False
C. True if it is declared static
D. None of the mentioned
Answer» B. False
21.

What is the precedence of arithmetic operators (from highest to lowest)?

A. %, *, /, +, –
B. %, +, /, *, –
C. +, -, %, *, /
D. %, +, -, *, /
Answer» A. %, *, /, +, –
22.

Which of the following is not an arithmetic operation?

A. a * = 10;
B. a / = 10;
C. a ! = 10;
D. a % = 10;
Answer» C. a ! = 10;
23.

Which of the following data type will throw an error on modulus operation(%)?

A. char
B. short
C. int
D. float
Answer» D. float
24.

Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only?

A. +, –
B. +, -, %
C. +, -, *, /
D. +, -, *, /, %
Answer» A. +, –
25.

Are logical operator sequence points?

A. True
B. False
C. Depends on the compiler
D. Depends on the standard
Answer» A. True
26.

Do logical operators in the C language are evaluated with the short circuit?

A. True
B. False
C. Depends on the compiler
D. Depends on the standard
Answer» A. True
27.

What is the result of logical or relational expression in C?

A. True or False
B. 0 or 1
C. 0 if an expression is false and any positive number if an expression is true
D. None of the mentioned
Answer» B. 0 or 1
28.

Relational operators cannot be used on ____________

A. structure
B. long
C. strings
D. float
Answer» A. structure
29.

Which among the following is NOT a logical or relational operator?

A. !=
B. ==
D. =
Answer» D. =
30.

What is the type of the following assignment expression if x is of type float and y is of type int? y = x + y;

A. int
B. float
C. there is no type for an assignment expression
D. double
Answer» A. int
31.

What will be the value of the following assignment expression? (x = foo())!= 1 considering foo() returns 2

A. 2
B. True
C. 1
D. 0
Answer» A. 2
32.

Operation “a = a * b + a” can also be written as ___________

A. a *= b + 1;
B. (c = a * b)!=(a = c + a);
C. a = (b + 1)* a;
D. All of the mentioned
Answer» D. All of the mentioned
33.

What will be the final value of c in the following C statement? (Initial value: c = 2) c <<= 1;

A. c = 1;
B. c = 2;
C. c = 3;
D. c = 4;
Answer» D. c = 4;
34.

In expression i = g() + f(), first function called depends on __________

A. Compiler
B. Associativiy of () operator
C. Precedence of () and + operator
D. Left to write of the expression
Answer» A. Compiler
35.

Which operators of the following have same precedence? P. "!=", Q. "+=", R. "<<="

A. P and Q
B. Q and R
C. P and R
D. P, Q and R
Answer» B. Q and R
36.

Comment on the following statement n = 1; printf("%d, %dn", 3*n, n++);

A. Output will be 3, 2
B. Output will be 3, 1
C. Output will be 6, 1
D. Output is compiler dependent
Answer» D. Output is compiler dependent
37.

Which is correct representation of C statement? e = a * b + c / d * f;

A. e = (a * (b +(c /(d * f))));
B. e = ((a * b) + (c / (d * f)));
C. e = ((a * b) + ((c / d)* f));
D. Both e = ((a * b) + (c / (d * f))); and e = ((a * b) + ((c / d)* f));
Answer» D. Both e = ((a * b) + (c / (d * f))); and e = ((a * b) + ((c / d)* f));
38.

While swapping 2 no’ what at precautions to be taken care? b = (b / a); a = a * b; b = a / b;

A. Data type should be either of short, int and long
B. Data type should be either of float and double
C. All data types are accepted except for (char *)
D. This code doesn’t swap 2 numbers
Answer» B. Data type should be either of float and double
39.

function tolower(c) defined in library <ctype.h> works for ___________

A. Ascii character set
B. Unicode character set
C. Ascii and utf-8 but not EBCDIC character set
D. Any character set
Answer» D. Any character set
40.

Which type of conversion is NOT accepted?

A. From char to int
B. From float to char pointer
C. From negative int to char
D. From double to char
Answer» B. From float to char pointer
41.

Which of the following type-casting have chances for wrap around?

A. From int to float
B. From int to char
C. From char to short
D. From char to int
Answer» B. From int to char
42.

Which of the following typecasting is accepted by C?

A. Widening conversions
B. Narrowing conversions
C. Widening & Narrowing conversions
D. None of the mentioned
Answer» C. Widening & Narrowing conversions
43.

When do you need to use type-conversions?

A. The value to be stored is beyond the max limit
B. The value to be stored is in a form not supported by that data type
C. To reduce the memory in use, relevant to the value
D. All of the mentioned
Answer» D. All of the mentioned
44.

What is the scope of an external variable?

A. Whole source file in which it is defined
B. From the point of declaration to the end of the file in which it is defined
C. Any source file in a program
D. From the point of declaration to the end of the file being compiled
Answer» D. From the point of declaration to the end of the file being compiled
45.

What is the scope of a function?

A. Whole source file in which it is defined
B. From the point of declaration to the end of the file in which it is defined
C. Any source file in a program
D. From the point of declaration to the end of the file being compiled
Answer» D. From the point of declaration to the end of the file being compiled
46.

In the standard library of C programming language, which of the following header file is designed for basic mathematical operations?

A. math.h
B. conio.h
C. dos.h
D. stdio.h
Answer» A. math.h
47.

Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?

A. rem = 3.14 % 2.1;
B. rem = modf(3.14, 2.1);
C. rem = fmod(3.14, 2.1);
D. Remainder cannot be obtain in floating point division.
Answer» C. rem = fmod(3.14, 2.1);
48.

By default a real number is treated as a

A. A.float
B. B.double
C. C.long double
D. D. far double
Answer» B. B.double

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.