Q: 1 The meaning of each ________is fixed. We can simply use them for its intended meaning.
Identifier
Constant
Variable
Keywords
[ Option D ]
In C programming, keywords are special words that have a fixed and predefined meaning, decided by the language itself. We cannot change their meaning, nor can we use them as identifiers.
| Related to Primitive Data Types | Related to Control Statement | Related to Storage Classes | Related to User-Defined Data Type | Other Purpose |
|---|---|---|---|---|
| int | if | auto | struct | const |
| char | else | static | union | sizeof |
| float | switch | register | enum | volatile |
| double | case | extern | typedef | |
| short | default | |||
| long | break | |||
| signed | continue | |||
| unsigned | goto | |||
| void | do | |||
| while | ||||
| for | ||||
| return |
Q: 2 Which of the following is not a valid variable name in most programming languages?
myVariable
123Variable
_myVariable
More than one of the above
[ Option B ]
A variable is a named location in memory that is used to hold or store the value. The value of variable can be modified in the program by the instruction. The variable names must follow the rules of identifiers.
RULES FOR WRITING IDENTIFIERS:
| Variable Name | Result | Why? |
|---|---|---|
| myVariable | Valid. | Starts with a letter, follows identifier rules. |
| 123Variable | Invalid. | Variable names cannot start with digits. |
| _myVariable | Valid. | First character is underscore. Alphabets and underscore is allowed as the first character. |
Q: 3 During entire program execution the value of ___________ cannot be changed.
Variable
Constant
Literals
Function
[ Option B ]
In programming like C, we store information using variables or other fixed items. Some values need to stay the same forever during the whole program run, like math number PI, number of days in a week, or maximum speed limit etc.
A constant is a value that is fixed and cannot be changed during the execution of a program. Constants are used when we want to make sure a value remains the same throughout the program.
#include <stdio.h>
int main()
{
int age = 29;// Variable.
printf("Age : %d ", age);
age = 34; // Changing value of variable.
printf("Updated Age : %d ", age);
const float PI = 3.14;// Constant.
printf("Value of PI: %.2f ", PI);
PI = 3.1415; // Error. Cannot change a constant.
return 0;
}
Q: 4 A comment:
Is a note that can be put into the source code
Is ignored by the compiler
Starts with the /* and end with the */ character pair
All of the above
[ Option D ]
A comment is used to add notes or explanations within the source code to make it easier for humans to understand. Comments are ignored by the compiler, so they do not affect the execution of the program.
In C, a multi-line comment starts with /* and ends with */. Single-line comments can also be written using //.
Q: 5 In context of C language, the word ‘if’ is a
Conjunction
Keyword
Identifier
Both (a) and (b)
[ Option B ]
In C language the if is keywords. A keyword is a reserved word that has a predefined meaning in the language and cannot be used as an identifier. The if is used for decision-making.
Q: 6 The backslash constant ‘ ’ can be used for? Choose best answer.
Move cursor back to one position
Move cursor top of console window
Move cursor beginning to current line
Move cursor beginning to previous line
[ Option C ]
The backslash constant is called the carriage return. It moves the cursor back to the beginning of the current line, without moving to a new line or erasing any existing content. This allows the next characters to overwrite the existing characters on the same line.
Q: 7 Which of the following statement(s) is/are correct?
I. Keywords are those words whose meaning is already defined by Compiler.
II. Keywords cannot be used as variable name.
III. There are 32 keywords in ANSI C.
IV. C keywords are also called as reserved words.
I and II only
II and III only
I, II and IV only
I, II, III and IV
[ Option D ]
Must Know:
| Keyword | Description |
| _Bool | Represents Boolean data type. In C, 0 (zero) is treated as false and any non-zero value is treated as true. |
| _Complex | Represents complex numbers (real + imaginary). |
| _Imaginary | Represents imaginary numbers (pure imaginary part). |
| inline | Suggests the compiler to expand the function inline to reduce call overhead. |
| restrict | A pointer qualifier that tells compiler the pointer is the only way to access data. |
Q: 8 The keyword ‘const’ keeps the value of a variable _________.
Mutable
Variant
Constant
Both (b) and (c)
[ Option C ]
The keyword const is used when we want to make sure that the value of a variable cannot be changed after it is assigned. When a variable is declared with const, it becomes a constant, meaning its value remains the same throughout the program.
Q: 9 The header file necessary to do mathematical calculation.
alloc.h
stdio.h
string.h
math.h
[ Option D ]
In C language, the header file math.h contains the prototypes of mathematical functions such as sqrt(), pow(), sin(), cos(), and log(). By including this header file at the beginning of a program using #include<math.h>, we can use these predefined functions to perform various mathematical calculations.
Q: 10 The name of identifier in C language must be starts from alphabets or______?
# (hash)
* (asterisk)
_ (underscore)
None of these
[ Option C ]
Combination of letters becomes an identifier. Identifiers are used for give the names of various program elements like variables, array, functions, structure etc.
RULES FOR WRITING IDENTIFIERS:
Q: 11 The __________ cannot be used as an identifier.
Keyword
Variable
Constant
All of the above
[ Option A ]
An identifier is the name we give to various program elements like variables, constants, functions, and other user-defined items. However, keywords cannot be used as identifiers because of meaning of each keyword is fixed or already known by the compiler.
Q: 12 Which one of the following is not a keyword for C language?
case
main
default
sizeof
[ Option B ]
The keywords are special words that have a fixed and predefined meaning, decided by the language itself.
| Related to Primitive Data Types | Related to Control Statement | Related to Storage Classes | Related to User-Defined Data Type | Other Purpose |
|---|---|---|---|---|
| int | if | auto | struct | const |
| char | else | static | union | sizeof |
| float | switch | register | enum | volatile |
| double | case | extern | typedef | |
| short | default | |||
| long | break | |||
| signed | continue | |||
| unsigned | goto | |||
| void | do | |||
| while | ||||
| for | ||||
| return |
The main is the name of the function where program execution begins, but it is not reserved by the C compiler as a keyword.
Q: 13 The backslash constant ‘’ can be used for? Choose best answer.
Move cursor back to one position in current line
Move cursor back to one position in current line in destructive nature
Move cursor back to five positions in current line in non-destructive nature
None of these
[ Option A ]
The backslash constant (backspace) moves the cursor one position back in the current line. It does not erase or delete the character. It only shifts the cursor position so that the next character printed will overwrite the previous one.
The C language defines several backslash character constants which are used for special purpose. They are called so because each backslash constant starts with backslash (). These are also called white spaces characters or escape sequence characters.
| ESCAPE SEQUENCE | MEANING |
|---|---|