Introduction To C Programming Quiz

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Ngonzaga
N
Ngonzaga
Community Contributor
Quizzes Created: 2 | Total Attempts: 13,843
Questions: 20 | Attempts: 12,426

SettingsSettingsSettings
Introduction To C Programming Quiz - Quiz

Play this amazing quiz that covers the questions related to introduction to C programming. Whether you are a hardcore C programmer or just have started learning about it, playing this quiz will absolutely benefit you and you'd be able to learn some new terms related to the C language. C is a general-purpose programming language used to develop software. Dennis M. Ritchie developed it in 1972. Do you think you can easily score well on the test? Take it up and check your result.


Questions and Answers
  • 1. 

    A placeholder begins with the symbol _____.

    • A.

      *

    • B.

      !

    • C.

      %

    • D.

      &

    Correct Answer
    C. %
    Explanation
    A placeholder begins with the symbol %.

    Rate this question:

  • 2. 

    The "\n" character does which of the following operations?

    • A.

      Double line spacing

    • B.

      Character deletion

    • C.

      Character backspace

    • D.

      Places cursor on the next line

    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.

    Rate this question:

  • 3. 

    #define PI 3.14159 The above code represents which of the following?

    • A.

      Preprocessor directive

    • B.

      Variable

    • C.

      Constant macro

    • D.

      Macro

    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.

    Rate this question:

  • 4. 

    Which symbol separates variable names?

    • A.

      &

    • B.

      . (period)

    • C.

      ' (apostrophe)

    • D.

      , (comma)

    • E.

      ; (semicolon)

    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)".

    Rate this question:

  • 5. 

    Which symbol terminates a C statement?

    • A.

      . (period)

    • B.

      ; (semicolon)

    • C.

      : (colon)

    • D.

      , (comma)

    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.

    Rate this question:

  • 6. 

    The ___________ ignores comments and they are not translated into machine language.

    • A.

      Compiler

    • B.

      Translator

    • C.

      Both

    • D.

      None

    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."

    Rate this question:

  • 7. 

    Which of the following represent comments in C?

    • A.

      <, >

    • B.

      [ , ]

    • C.

      /*, /*

    • D.

      */, /*

    • E.

      /*, */

    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.

    Rate this question:

  • 8. 

    Which arithmetic operator in C returns the integer remainder of the result of dividing its first operand by its second?

    • A.

      %

    • B.

      /

    • C.

      \

    • D.

      *

    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.

    Rate this question:

  • 9. 

    Which of the following is a valid name for an identifier in C?

    • A.

      !Here

    • B.

      4Me_To_You

    • C.

      Emp_Num1

    • D.

      All of the above points

    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.

    Rate this question:

  • 10. 

    Which of the following operations gets evaluated first?

    • A.

      * - multiplication

    • B.

      () - parentheses

    • C.

      / - division

    • D.

      + - addition

    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.

    Rate this question:

  • 11. 

    If your program gets an error when dividing by zero, this type of error is called?

    • A.

      Syntax

    • B.

      Run-time

    • C.

      Undetected

    • D.

      Logic

    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.

    Rate this question:

  • 12. 

    Your C program was able to compile. However, the result is incorrect. What type of error is this?

    • A.

      Undetected

    • B.

      Run-time

    • C.

      Syntax

    • D.

      Logic

    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.

    Rate this question:

  • 13. 

    Your C program always fails to compile and has these errors. What type of errors are present?

    • A.

      Syntax

    • B.

      Run-time

    • C.

      Logic

    • D.

      Undetected

    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.

    Rate this question:

  • 14. 

    The section of C code after the preprocessor directives is generally for?

    • A.

      User-defined function definitions

    • B.

      Function prototypes

    • C.

      Variables

    • D.

      Datatypes

    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.

    Rate this question:

  • 15. 

    Is the syntax for the following C statement correct?: scanf("%d", input);

    • A.

      True

    • B.

      False

    • C.

      Not clear

    • D.

      Can't say

    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.

    Rate this question:

  • 16. 

    When a C program asks the user to input data using the keyboard, the program is said to be in __________ mode.

    • A.

      Batch

    • B.

      Interactive

    • C.

      Preprocessor

    • D.

      Saving

    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.

    Rate this question:

  • 17. 

    What is the value of result after executing the following statement?result = 6 + 4 * 5 / 2

    • A.

      25

    • B.

      22

    • C.

      16

    • D.

      60

    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.

    Rate this question:

  • 18. 

    You can have ____________ main function(s).

    • A.

      Only one

    • B.

      Two

    • C.

      More than two

    • D.

      Can't say

    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.

    Rate this question:

  • 19. 

    In general, the body of a function is represented by the following symbols?

    • A.

      [, ]

    • B.

      {, }

    • C.

      /, \

    • D.

      /*, */

    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.

    Rate this question:

  • 20. 

    A number such as 45.567 needs to be stored in a variable of which data type?

    • A.

      Int

    • B.

      Char

    • C.

      Double

    • D.

      Float

    • E.

      C and D

    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.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Apr 17, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 19, 2010
    Quiz Created by
    Ngonzaga
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.