It102 Programming Fundamentals: 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 Anthzila
A
Anthzila
Community Contributor
Quizzes Created: 35 | Total Attempts: 42,158
Questions: 34 | Attempts: 121

SettingsSettingsSettings
It102 Programming Fundamentals: Quiz! - Quiz

.


Questions and Answers
  • 1. 

    Which of the following is a sign used for comments?

    • A.

      /

    • B.

      *

    • C.

      //

    Correct Answer
    C. //
    Explanation
    The double forward slash "//" is a sign used for comments in programming languages like C++, Java, and JavaScript. It is used to add explanatory or descriptive text within the code that is not executed by the program. These comments are helpful for programmers to make their code more readable and understandable for themselves and other developers who may work on the code in the future.

    Rate this question:

  • 2. 

    Why is it important to include the file conio.h?

    • A.

      Because getch() function relies on this file

    • B.

      It adds a function to the main program

    • C.

      Because the header is required to start the program

    Correct Answer
    A. Because getch() function relies on this file
    Explanation
    The correct answer is "because getch() function relies on this file." The conio.h file contains the declaration for the getch() function, which is used to read a single character from the keyboard. Without including this file, the program would not be able to use the getch() function, leading to errors or incorrect behavior when trying to read user input.

    Rate this question:

  • 3. 

    This line corresponds to the beginning of the definition of the main function of the program.

    • A.

      Int main()

    • B.

      Using namespace std;

    • C.

      #inlcude

    Correct Answer
    A. Int main()
    Explanation
    The given answer "int main()" is the correct answer because it represents the declaration of the main function in the program. In C++ programming, the main function is the entry point of the program where the execution begins. It has a return type of "int" which indicates that the function will return an integer value.

    Rate this question:

  • 4. 

     x=1; y=0;if (x==1 && y>x)    cout<

    • A.

      10

    • B.

      0 1

    • C.

      1 0

    • D.

      01

    Correct Answer
    C. 1 0
    Explanation
    The given code snippet initializes two variables, x with a value of 1 and y with a value of 0. The if statement checks if x is equal to 1 and if y is greater than x. Since y is not greater than x, the condition evaluates to false and the code inside the if statement is not executed. Therefore, there is no output and the answer is an empty string.

    Rate this question:

  • 5. 

    ______ is used to mark the end of the statement.

    • A.

      Colon

    • B.

      Semicolon

    • C.

      Period

    Correct Answer
    B. Semicolon
    Explanation
    A semicolon is used to mark the end of a statement when the writer wants to connect two closely related independent clauses. It is used as a stronger punctuation mark than a comma but not as final as a period. The semicolon allows for a smoother flow between the two clauses while still indicating a separation.

    Rate this question:

  • 6. 

    A portion of memory to store a determined valued is referred to as _________.

    • A.

      Identifier

    • B.

      Variable

    • C.

      String

    Correct Answer
    B. Variable
    Explanation
    A portion of memory to store a determined value is referred to as a variable. Variables are used to hold and manipulate data in a computer program. They have a specific type, such as integer, float, or string, which determines the kind of data that can be stored in them. Variables are named entities that can be assigned values and used in calculations or operations throughout the program. They provide a way to store and access data dynamically during the execution of a program.

    Rate this question:

  • 7. 

    Which of the following is not a valid identifier?

    • A.

      !x

    • B.

      X

    • C.

      X_y

    Correct Answer
    A. !x
    Explanation
    An identifier in programming is a name used to identify a variable, function, or any other user-defined item. In this case, "!x" is not a valid identifier because it starts with an exclamation mark, which is not allowed in most programming languages. Identifiers typically cannot start with special characters or symbols, except for underscores. Therefore, "!x" does not meet the criteria of a valid identifier.

    Rate this question:

  • 8. 

    Which of the following is a valid identifier?

    • A.

      Cout

    • B.

      Int

    • C.

      _pi

    Correct Answer
    C. _pi
    Explanation
    The identifier "_pi" is a valid identifier because it starts with an underscore, which is allowed in the naming conventions for identifiers in many programming languages. It also consists of alphanumeric characters, which is another requirement for a valid identifier. Therefore, "_pi" meets the criteria for a valid identifier.

    Rate this question:

  • 9. 

    What are the things to avoid in creating variable identifiers?

    • A.

      Using reserve words

    • B.

      Starting with a number

    • C.

      Using spaces

    • D.

      Combining capital and small letters in one word

    Correct Answer(s)
    A. Using reserve words
    B. Starting with a number
    C. Using spaces
    Explanation
    The correct answer for this question is using reserve words, starting with a number, and using spaces. These are all common mistakes to avoid when creating variable identifiers. Reserve words are words that are already reserved for specific purposes in programming languages, so using them as variable names can lead to errors. Starting a variable identifier with a number is also not allowed in most programming languages. Using spaces in variable names can cause confusion and make the code harder to read. Finally, combining capital and small letters in one word can make the code less consistent and harder to understand.

    Rate this question:

  • 10. 

    When programming, the variables used are stored in the memory.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    In programming, variables are used to store data that can be manipulated and accessed by the program. These variables need to be stored in the computer's memory in order for the program to work with them. Therefore, the statement "When programming, the variables used are stored in the memory" is true.

    Rate this question:

  • 11. 

    When variables are used, it is important to know what kind of data we want to store them.  This is referred to as ______.

    • A.

      Data Types

    • B.

      Data Expression

    • C.

      Assignment Statement

    Correct Answer
    A. Data Types
    Explanation
    When using variables, it is crucial to determine the type of data that will be stored in them. This is known as data types. Data types define the kind of values that can be assigned to a variable, such as integers, floating-point numbers, characters, or booleans. By specifying the data type, we ensure that the variable can only store values of that specific type, which helps in maintaining data integrity and preventing errors.

    Rate this question:

  • 12. 

    Which of the following is the correct way on declaring variables?

    • A.

      Int a

    • B.

      Int a;

    • C.

      Int a:

    Correct Answer
    B. Int a;
    Explanation
    The correct way of declaring variables is by using the syntax "int a;". This declares a variable named "a" of type integer. The semicolon at the end indicates the end of the declaration statement.

    Rate this question:

  • 13. 

    What type of data is used when using whole numbers?

    • A.

      Int

    • B.

      Float

    • C.

      Char

    Correct Answer
    A. Int
    Explanation
    When using whole numbers, the data type used is "int." The "int" data type is short for integer and is used to represent whole numbers without any decimal places. It can store both positive and negative numbers within a certain range determined by the programming language being used. Therefore, "int" is the correct data type for working with whole numbers.

    Rate this question:

  • 14. 

    Analyze the following example: x = 4530.908; What type of data that the identifier x holds?

    • A.

      Int

    • B.

      Float

    • C.

      Char

    Correct Answer
    B. Float
    Explanation
    The identifier "x" holds a float data type. This is because the value assigned to "x" contains a decimal point, which indicates a floating-point number. The float data type is used to represent numbers with decimal places in programming.

    Rate this question:

  • 15. 

    Analyze the following example:#include <iostream>using namespace std;int main(){   int x;     x = 'y';     cout<<'y';} What is the correct data type of x? 

    • A.

      Char

    • B.

      Float

    • C.

      String

    Correct Answer
    A. Char
    Explanation
    The correct data type of x in this example is char. This is because the variable x is assigned the value 'y', which is a character literal. The data type char is used to store single characters in C++.

    Rate this question:

  • 16. 

    What is the data type when variables hold values of a series of characters?

    • A.

      Char

    • B.

      String

    • C.

      Float

    Correct Answer
    B. String
    Explanation
    When variables hold values of a series of characters, the data type used is "string". A string is a sequence of characters enclosed within quotation marks. It allows for the storage and manipulation of text data. In programming, strings are commonly used to represent words, sentences, or any other textual information.

    Rate this question:

  • 17. 

    Analyze the following situation: #include <iostream> using namespace std; int main() {   char a;     a='1';     cout<<'a'; } Does the program run?

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    Explanation
    Yes, the program runs. The program includes the necessary header file "iostream" and uses the "std" namespace. It declares a variable "a" of type char and assigns the value '1' to it. Then it prints the value of "a" using the "cout" statement. Since all the necessary components are present and there are no syntax errors, the program will run successfully.

    Rate this question:

  • 18. 

    Analyze the following situation: #include <iostream> using namespace std; int main() {   float a,b,     char sum,c;     a = 1.5;     b = 2.5;     c = '3';     sum = c;     cout<<sum; } Will the program run correctly?

    • A.

      Yes. The program will run correctly.

    • B.

      No. The program is will not run because of errors.

    Correct Answer
    A. Yes. The program will run correctly.
    Explanation
    The program will run correctly because there are no syntax errors in the code. The variables 'a' and 'b' are declared as float, 'sum' is declared as char, and 'c' is assigned the value '3' as a character. The value of 'c' is then assigned to 'sum' and printed, which will output the character '3'.

    Rate this question:

  • 19. 

    You can check more than one choice on the following question. Which of the following is the correct way in initializing variables?

    • A.

      Int a = 0

    • B.

      Int a = 0'

    • C.

      Float x (0);

    • D.

      Int x =0;

    • E.

      Char y = 'a';

    Correct Answer(s)
    D. Int x =0;
    E. Char y = 'a';
    Explanation
    The correct way to initialize variables is by using the syntax "int x = 0;" and "char y = 'a';". This syntax assigns the value of 0 to the integer variable x and assigns the character 'a' to the character variable y. The other options are incorrect because they either have syntax errors (int a = 0') or use incorrect syntax for initialization (float x (0)).

    Rate this question:

  • 20. 

    Analyze the following situation: #include <iostream> int main() {  int x;     x = "hello world";     cout<

    • A.

      Yes. The program is correct.

    • B.

      No. Lacking of variable declaration in the include section so it will not work.

    • C.

      No. The program does not work because of incompatible data type in the variable assignment.

    Correct Answer
    C. No. The program does not work because of incompatible data type in the variable assignment.
    Explanation
    The program does not work because the variable "x" is declared as an integer, but it is assigned a string value ("hello world"). This is an incompatible data type assignment and will result in a compilation error.

    Rate this question:

  • 21. 

    Which of the following is an example of a variable assignment?

    • A.

      X = 5;

    • B.

      #define x 5

    • C.

      Const int x;

    Correct Answer
    A. X = 5;
    Explanation
    The correct answer is "x = 5;" because it demonstrates the assignment of the value 5 to the variable x. This is a typical example of variable assignment, where a variable is assigned a specific value for later use in the program. The other options, "#define x 5" and "const int x;", do not involve variable assignment but rather define constants or macros.

    Rate this question:

  • 22. 

    Which of the following slash codes creates a new line?

    • A.

      \t

    • B.

      \n

    • C.

      \\

    Correct Answer
    B. \n
    Explanation
    The slash code that creates a new line is "\n".

    Rate this question:

  • 23. 

    The symbol { means?

    • A.

      Begin

    • B.

      End

    • C.

      Stop

    Correct Answer
    A. Begin
    Explanation
    The symbol { typically represents the beginning of a block of code or a section in programming languages. It is used to indicate the start of a code segment or a loop.

    Rate this question:

  • 24. 

    The modulo operator  (%) returns ______ of a division operation.   

    • A.

      Quotient

    • B.

      Dividend

    • C.

      Remainder

    Correct Answer
    C. Remainder
    Explanation
    The modulo operator (%) returns the remainder of a division operation.

    Rate this question:

  • 25. 

    Analyze the following program: #include <iostream> using namespace std; int main() {  int x,y, z;    int a,b;    x=10;    y=x % 2;    z = x + y * 2;    x=z;    a=x+y;    b=a-5; } What is the final value of b?

    Correct Answer
    5
    Explanation
    The final value of b is 5 because the value of x is initially 10. Then, y is assigned the value of x % 2, which is 0. Next, z is calculated as x + y * 2, which is 10 + 0 * 2 = 10. x is then assigned the value of z, which is 10. a is calculated as x + y, which is 10 + 0 = 10. Finally, b is calculated as a - 5, which is 10 - 5 = 5. Therefore, the final value of b is 5.

    Rate this question:

  • 26. 

    Analyze the following program:#include <iostream>using namespace std;int main(){  int x,y, z;   int a,b;   x=10;   y=x;   z = x+y;   x=z;   a=x+y;   b=a-5;}What is the final value of b?

    Correct Answer
    25
    Explanation
    The final value of b is 25 because the program assigns the value of 10 to x, then assigns the value of x to y. It then adds x and y together and assigns the result to z. Next, it assigns the value of z to x. After that, it adds x and y together and assigns the result to a. Finally, it subtracts 5 from a and assigns the result to b. Since the value of a is 25, subtracting 5 from it gives us the final value of b, which is also 25.

    Rate this question:

  • 27. 

    The ____ operator is used to compare data.

    • A.

      ==

    • B.

      =

    • C.

      >

    Correct Answer
    A. ==
    Explanation
    The == operator is used to compare data. It checks if the values on both sides of the operator are equal. If they are equal, it returns true; otherwise, it returns false. This operator is commonly used in programming languages to compare variables, values, or expressions.

    Rate this question:

  • 28. 

    What does the command count mean?

    • A.

      It causes to print something in the screen.

    • B.

      It allows users to loop to the main program

    • C.

      It causes the main function to run.

    Correct Answer
    A. It causes to print something in the screen.
    Explanation
    The command count is used to print something on the screen. It is a function or statement that displays a specified message or value to the user. This can be useful for providing information or feedback to the user during program execution. By using the count command, the program can output relevant data or messages to the screen, enhancing the user experience and providing important information.

    Rate this question:

  • 29. 

    What is the purpose of debugging a program?

    • A.

      To check the program for errors.

    • B.

      To run the program

    • C.

      To save the program.

    Correct Answer
    A. To check the program for errors.
    Explanation
    The purpose of debugging a program is to check the program for errors. Debugging involves identifying and fixing any issues or bugs in the code that may cause the program to malfunction or produce incorrect results. By debugging, programmers can ensure that the program is running correctly and as intended, improving its functionality and reliability. Debugging is an essential step in the software development process, allowing programmers to identify and resolve any errors before the program is deployed or released to users.

    Rate this question:

  • 30. 

    What function lets you create programs that can process keyboard input?

    • A.

      Cin

    • B.

      Cout

    • C.

      Getch()

    Correct Answer
    A. Cin
    Explanation
    The correct answer is "cin". The cin function in C++ allows the programmer to read input from the keyboard. It is used to receive input from the user during program execution. This input can then be processed and used by the program to perform various tasks or calculations. The cin function is commonly used in conjunction with the >> operator to extract input values from the keyboard and store them in variables for further use in the program.

    Rate this question:

  • 31. 

    Analyze the following program: #include <stdio.h> int main() { char x;   x = 1; } Is 1 declared properly in variable x?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    In the given program, variable x is declared as a character data type. However, the value assigned to x is an integer (1). In C programming, it is not valid to assign an integer value to a character variable without explicitly casting it. Therefore, 1 is not declared properly in variable x.

    Rate this question:

  • 32. 

     x=10; y=2;if (x%y == y)   x = x * y - 5;else  x = x * 2 / y;y = x;cout<

    Correct Answer
    1010
    Explanation
    The code first checks if the remainder of x divided by y is equal to y. Since 10 divided by 2 is 5 with no remainder, the condition is true. Therefore, x is updated to be the product of x and y (10*2) minus 5, which is 15. The else condition is skipped. Finally, y is assigned the value of x, which is 15. The output of the code will be 1010.

    Rate this question:

  • 33. 

    What is the result of the following logical expression?x=12; y=x%4; z = x / (y+2);T && !F II (y>z && !F)  

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The logical expression evaluates to True because all the conditions in the expression are true. The variable x is assigned the value 12, y is assigned the remainder of x divided by 4 which is 0, and z is assigned the result of x divided by (y+2) which is 12/2 = 6. The first condition T (True) is true. The second condition !F (not False) is also true. The third condition (y>z && !F) is true because 0 is greater than 6 and not False. Therefore, the overall logical expression is true.

    Rate this question:

  • 34. 

    X = 1; x = 2; y = x; X = x; Y = x + 2 * X; What is the value of last variable?

    Correct Answer
    6
    Explanation
    The value of the last variable is 6. This is because the value of X is initially set to 1, then it is updated to 2. The value of y is assigned as the current value of x, which is 2. Then, X is updated to the current value of x, which is 2. Finally, Y is assigned the value of x + 2 * X, which is 2 + 2 * 2 = 6.

    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
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 25, 2011
    Quiz Created by
    Anthzila
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.