1.
A placeholder begins with the symbol _____.
Correct Answer
C. %
Explanation
A placeholder begins with the symbol %.
2.
The "\n" character does which of the following operations?
Correct Answer
D. Places cursor on the next line
Explanation
The "" character is an HTML tag used to create a line break or a new line in a webpage. When this tag is encountered in the HTML code, it instructs the browser to move the cursor to the next line, effectively creating a line break in the displayed content.
3.
#define PI 3.14159
The above code represents which of the following?
Correct Answer
C. Constant macro
Explanation
The above code represents a constant macro. The #define directive is used to define a constant value, in this case, PI, which is assigned the value 3.14159. Constant macros are used to define constants that can be used throughout the code, and their values cannot be changed during the execution of the program.
4.
Which symbol separates variable names?
Correct Answer
D. , (comma)
Explanation
The comma symbol is used to separate variable names in programming languages. It is commonly used to list multiple variables in a declaration or when passing arguments to a function. For example, in Python, we can declare multiple variables in a single line by separating them with commas: "x, y, z = 1, 2, 3". Similarly, when passing arguments to a function, we can separate them with commas: "my_function(arg1, arg2, arg3)".
5.
Which symbol terminates a C statement?
Correct Answer
B. ; (semicolon)
Explanation
The semicolon (;) is used to terminate a C statement. In C programming, statements are typically ended with a semicolon to indicate the end of a line of code. This helps the compiler to understand the structure of the code and execute it correctly. Without the semicolon, the code may not compile or may produce unexpected results. Therefore, the semicolon is the symbol that is used to terminate a C statement.
6.
The ___________ ignores comments and they are not translated into machine language.
Correct Answer
A. Compiler
Explanation
A compiler is a program that converts human-readable code written in a high-level programming language into machine language that a computer can understand and execute. During this process, comments, which are annotations in the code meant for human understanding, are ignored by the compiler and not translated into machine language. Therefore, the correct answer is "compiler."
7.
Which of the following represent comments in C?
Correct Answer
E. /*, */
Explanation
The symbols /* and */ are used to represent comments in the C programming language. Comments are used to add explanatory notes or remarks to the code that are ignored by the compiler. The /* symbol is used to begin a comment and the */ symbol is used to end a comment. Anything between these symbols is considered a comment and is not executed as part of the program.
8.
Which arithmetic operator in C returns the integer remainder of the result of dividing its first operand by its second?
Correct Answer
A. %
Explanation
The arithmetic operator in C that returns the integer remainder of the result of dividing its first operand by its second is the modulus operator (%). This operator calculates the remainder after dividing the first operand by the second operand. For example, if we divide 10 by 3 using the modulus operator, the result will be 1, as 10 divided by 3 is 3 with a remainder of 1.
9.
Which of the following is a valid name for an identifier in C?
Correct Answer
C. Emp_Num1
Explanation
The identifier "Emp_Num1" is a valid name in C because it follows the rules for naming identifiers. In C, identifiers must start with a letter or an underscore, followed by any combination of letters, digits, or underscores. The identifier "Emp_Num1" begins with a letter, followed by a combination of letters and digits, making it a valid identifier in C. The other options, "!Here" and "4Me_To_You," are not valid identifiers because they start with characters other than a letter or an underscore.
10.
Which of the following operations gets evaluated first?
Correct Answer
B. () - parentheses
Explanation
Parentheses are evaluated first because they indicate a grouping of operations that should be performed before any other operations. The expressions inside the parentheses are evaluated first, allowing for the correct order of operations to be followed. This ensures that the result is accurate and consistent with mathematical conventions.
11.
If your program gets an error when dividing by zero, this type of error is called?
Correct Answer
B. Run-time
Explanation
When a program encounters an error while dividing by zero, it is referred to as a run-time error. This type of error occurs during the execution of the program, specifically at the moment when the division operation is being performed. Run-time errors are different from syntax errors, which occur when there is a mistake in the program's structure or syntax. Unlike syntax errors, run-time errors are not detected by the compiler and may cause the program to crash or behave unexpectedly during runtime.
12.
Your C program was able to compile. However, the result is incorrect. What type of error is this?
Correct Answer
D. Logic
Explanation
The given answer "logic" suggests that the error in the program is a logical error. A logical error occurs when the program runs without any syntax errors or runtime errors, but produces incorrect results due to a flaw in the logic or algorithm used in the program. In this case, the program was able to compile successfully, but the output is not what was expected, indicating a logical error in the code.
13.
Your C program always fails to compile and has these errors. What type of errors are present?
Correct Answer
A. Syntax
Explanation
The errors present in the C program are syntax errors. Syntax errors occur when the code violates the rules of the programming language, such as missing semicolons, incorrect variable declarations, or incorrect syntax structure. These errors prevent the program from being compiled successfully.
14.
The section of C code after the preprocessor directives is generally for?
Correct Answer
B. Function prototypes
Explanation
The section of C code after the preprocessor directives is generally for function prototypes. Function prototypes are declarations that provide information about the functions used in the code, including their names, return types, and parameter types. These prototypes allow the compiler to check for errors and ensure that the functions are used correctly before they are defined or implemented. By including function prototypes in this section, it helps to organize the code and make it more readable and maintainable.
15.
Is the syntax for the following C statement correct?:
scanf("%d", input);
Correct Answer
B. False
Explanation
The syntax for the given C statement is incorrect. The scanf function in C requires the address of the variable where the input should be stored. In this case, the address of the variable 'input' should be passed as an argument to scanf using the '&' operator. However, in the given statement, the '&' operator is missing before 'input'. Therefore, the correct answer is False.
16.
When a C program asks the user to input data using the keyboard, the program is said to be in __________ mode.
Correct Answer
B. Interactive
Explanation
When a C program asks the user to input data using the keyboard, the program is said to be in interactive mode. This means that the program is actively engaging with the user, allowing them to provide input and receive output in real-time. In interactive mode, the program waits for user input before proceeding further, making it suitable for scenarios where user interaction is required.
17.
What is the value of result after executing the following statement?result = 6 + 4 * 5 / 2
Correct Answer
C. 16
Explanation
The given statement uses the order of operations, also known as PEMDAS, to evaluate the expression. According to this rule, multiplication and division should be performed before addition and subtraction. So, first, 4 is multiplied by 5, resulting in 20. Then, 20 is divided by 2, giving the value of 10. Finally, 6 is added to 10, resulting in a final value of 16.
18.
You can have ____________ main function(s).
Correct Answer
A. Only one
Explanation
The correct answer is "only one" because in programming, a main function is the entry point of a program. It is responsible for executing the code and controlling the flow of the program. Having multiple main functions would create confusion and ambiguity in determining which function should be executed first. Therefore, only one main function is allowed in a program.
19.
In general, the body of a function is represented by the following symbols?
Correct Answer
B. {, }
Explanation
The answer {, } is correct because in most programming languages, the body of a function is enclosed within curly brackets. These brackets define the scope of the function and contain the statements or code that will be executed when the function is called. The opening curly bracket { marks the beginning of the function body, and the closing curly bracket } marks the end of the function body.
20.
A number such as 45.567 needs to be stored in a variable of which data type?
Correct Answer
E. C and D
Explanation
The double data type is chosen here for its ability to handle floating-point numbers with more precision than float. This makes it suitable for a number such as 45.567, ensuring accuracy in calculations and data representation. The int type can only store integers, and char is used for storing single characters, making them inappropriate choices for this requirement.