Section H PC Quiz 1

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By ABC
A
ABC
Community Contributor
Quizzes Created: 1 | Total Attempts: 125
| Attempts: 125
SettingsSettings
Please wait...
  • 1/70 Questions

    Which is an incorrect variable name?

    • Id_No
    • ID_NO_23
    • Id No
    • IdNo12
Please wait...
About This Quiz

This quiz assesses knowledge on basic programming syntax, including variable naming, operator precedence, and reserved keywords in programming languages.

Section H PC Quiz 1 - Quiz

Quiz Preview

  • 2. 

    If 'a' is an integer variable, then a=5/2 will return a value

    • 2.5

    • 2

    • 3

    • 2.5

    Correct Answer
    A. 2
    Explanation
    The expression "a=5/2" assigns the value of the division 5/2 to the variable 'a'. In integer division, the result is the quotient without any decimal places. Therefore, the result of 5/2 is 2, and this value will be assigned to 'a'.

    Rate this question:

  • 3. 

    Which of the follwing symbol is format specifier?

    • &

    • :

    • %d

    • ;

    Correct Answer
    A. %d
    Explanation
    The symbol "%d" is a format specifier. In programming, format specifiers are used to define the type and format of data that should be printed or read. In this case, "%d" is used to format and print an integer value.

    Rate this question:

  • 4. 

    Which of the following is the valid variable name?

    • Dot.

    • Number

    • Stack-queue

    • #hash

    Correct Answer
    A. Number
    Explanation
    The variable name "number" is valid because it starts with a letter, which is a requirement for variable names in most programming languages. Additionally, it does not contain any special characters or symbols, and it consists of only alphanumeric characters.

    Rate this question:

  • 5. 

    How many keywords are there in C Language?

    • 23

    • 32

    • 31

    • None of the above

    Correct Answer
    A. 32
    Explanation
    There are 32 keywords in the C Language. Keywords are reserved words that have a specific meaning in the programming language and cannot be used as variable names or identifiers. These keywords are predefined and have a specific purpose in the C Language syntax.

    Rate this question:

  • 6. 

    Identify the correct way of variable declearation

    • 1A_B

    • A_B

    • If

    • AB@3

    Correct Answer
    A. A_B
    Explanation
    The correct way of variable declaration is A_B. Variable names can only contain letters, numbers, and underscores, and must start with a letter or an underscore. The option 1A_B is incorrect because it starts with a number. The option "if" is incorrect because it is a reserved keyword in most programming languages and cannot be used as a variable name. The option AB@3 is incorrect because it contains a special character (@) which is not allowed in variable names.

    Rate this question:

  • 7. 

    Keyword to define any constant variable

    • Const

    • Con

    • Cons

    • Constant

    Correct Answer
    A. Const
    Explanation
    The correct answer is "const". In programming, the keyword "const" is used to define a constant variable. A constant variable is a value that cannot be changed once it is assigned. By using the "const" keyword, the programmer can ensure that the value of the variable remains constant throughout the program.

    Rate this question:

  • 8. 

    The declaration "unsigned u" indicates u is a/an

    • Unsigned character

    • Unsigned integer

    • Character

    • None

    Correct Answer
    A. Unsigned integer
    Explanation
    The declaration "unsigned u" indicates that the variable "u" is an unsigned integer. The keyword "unsigned" is used to specify that the variable can only hold non-negative values and increases the range of positive values that can be stored. Therefore, "u" can store only positive integers or zero, and cannot hold negative values or characters.

    Rate this question:

  • 9. 

    If s and b are integers then purpose of the following program fragment is to: b = s + b ;s = b - s ; b = b - s ;

    • Transfer the contents of s to b

    • Transfer the content of b to s

    • Exchange (swap) the contents of s and b

    • Negate the contents of s and b

    Correct Answer
    A. Exchange (swap) the contents of s and b
    Explanation
    The purpose of the program fragment is to exchange (swap) the contents of s and b. This is achieved by using a temporary variable to store the value of one variable while the values of both variables are being swapped. The first line of code assigns the sum of s and b to b, effectively storing the value of s in b. The second line of code assigns the difference between b and s to s, which swaps the values of s and b. Finally, the third line of code assigns the difference between b and s to b, effectively storing the original value of b in s.

    Rate this question:

  • 10. 

    Which of this is invalid variable name

    • Sum

    • Double

    • Total_rate

    • Size2area

    Correct Answer
    A. Double
    Explanation
    The variable name "double" is invalid because it is a reserved keyword in many programming languages, including Java and C++. Reserved keywords have a special meaning in the language and cannot be used as variable names.

    Rate this question:

  • 11. 

    Scanf("%d", x); Why this statement will give error ?

    • Incorrect function name

    • It should be "&d" instead of "%d"

    • Absence of & before x

    • No space in function scanf

    Correct Answer
    A. Absence of & before x
    Explanation
    The absence of the "&" symbol before the variable "x" in the scanf() function will cause an error. The "&" symbol is used to pass the address of the variable to the function, allowing it to directly modify the value stored at that address. Without the "&" symbol, the function will not be able to access the memory location of the variable, resulting in an error.

    Rate this question:

  • 12. 

    Which one is allowed assignment in 'C'

    • A=b=c=8;

    • 2=a

    • #define XYZ=2.5 ;

    • P= 4/ c=3;

    Correct Answer
    A. A=b=c=8;
    Explanation
    The correct answer is "a=b=c=8;" because in C programming, multiple variables can be assigned the same value in a single statement. This statement assigns the value 8 to variables a, b, and c simultaneously.

    Rate this question:

  • 13. 

    Identify the correct sequence of steps to run a program

    • Code, compile, link, load and execute

    • Link, load, code, compile and execute

    • Code, compile, link, execute and load

    • Compile, code, link, load and execute

    Correct Answer
    A. Code, compile, link, load and execute
    Explanation
    The correct sequence of steps to run a program is to first write the code, then compile it to convert it into machine-readable instructions, followed by linking the compiled code with any necessary libraries or dependencies. After that, the program is loaded into memory, and finally, it is executed or run.

    Rate this question:

  • 14. 

    The Opertor which compares the two values is

    • Assignment

    • Relational

    • Unary

    • None

    Correct Answer
    A. Relational
    Explanation
    The correct answer is "Relational." Relational operators are used to compare two values and determine the relationship between them, such as whether one value is equal to, greater than, or less than the other. These operators include symbols like == (equal to), != (not equal to), > (greater than), < (less than), >= (greater than or equal to), and

    Rate this question:

  • 15. 

    Which of this is valid variable name

    • Col-total

    • Sum Total

    • First.name

    • Row_1

    Correct Answer
    A. Row_1
    Explanation
    The variable name "row_1" is valid because it follows the rules for naming variables. In most programming languages, variable names can only contain letters, numbers, and underscores. They cannot start with a number or contain any special characters or spaces. "row_1" satisfies these requirements and is therefore a valid variable name.

    Rate this question:

  • 16. 

    Which of this reserved keyword in C language ?

    • Size

    • From

    • Break

    • Key

    Correct Answer
    A. Break
    Explanation
    The correct answer is "break". In the C language, "break" is a reserved keyword that is used to terminate a loop or switch statement. It is used to exit a loop prematurely when a certain condition is met or to exit a switch statement after a specific case is executed. The use of "break" as a variable or function name is not allowed in C as it is reserved for this specific purpose.

    Rate this question:

  • 17. 

    Int main() { printf("%d", 0&&4);

    • 0

    • 4

    • 1

    • 2

    Correct Answer
    A. 0
    Explanation
    The code snippet `printf("%d", 0&&4);` uses the logical AND operator (`&&`) to evaluate the expression `0&&4`. In this case, the expression evaluates to `0` because both operands are non-zero values. According to the rules of the logical AND operator, if any of the operands is `0`, the result is `0`. Therefore, the output of the `printf` statement will be `0`.

    Rate this question:

  • 18. 

    Which language does not need any translator?

    • Machine language

    • High level language

    • Assembly language

    • None

    Correct Answer
    A. Machine language
    Explanation
    Machine language does not need any translator because it is the lowest-level programming language that can be directly understood and executed by a computer's hardware. It consists of binary code instructions that are specific to the computer's architecture. As a result, no translation or interpretation is required for the computer to understand and execute the instructions in machine language.

    Rate this question:

  • 19. 

    An expression contains relational, assignment and arithmetic operators. If parenthesis are not specified, the order of evaluation of the operators would be:

    • Assignment, arithmetic, relational

    • Arithmetic, relational, assignment

    • Assignment, relational, arithmetic

    • Relational, assignment, arithmetic

    Correct Answer
    A. Arithmetic, relational, assignment
    Explanation
    The given answer is "arithmetic, relational, assignment". In an expression without specified parentheses, the arithmetic operators are evaluated first, followed by the relational operators, and finally the assignment operators. This order ensures that any necessary calculations are performed before making comparisons and assigning values to variables.

    Rate this question:

  • 20. 

    Operator & is used for

    • Bitwise AND

    • Bitwise OR

    • Bitwise NOT

    • None of the above

    Correct Answer
    A. Bitwise AND
    Explanation
    The operator "&" is used for performing a bitwise AND operation. Bitwise AND compares the corresponding bits of two numbers and returns a new number where each bit is set to 1 only if both corresponding bits in the original numbers are 1. This operator is commonly used in programming to manipulate individual bits within binary numbers.

    Rate this question:

  • 21. 

    Int a; a=15^13; printf("%d", a);

    • 3

    • 4

    • 2

    • 10

    Correct Answer
    A. 2
    Explanation
    The given code calculates the bitwise XOR of 15 and 13, which results in 2. The XOR operation compares the corresponding bits of two numbers and returns 1 if they are different, and 0 if they are the same. In this case, the binary representation of 15 is 1111 and the binary representation of 13 is 1101. When performing the XOR operation, the bits that are different are set to 1, resulting in the binary representation of 2, which is 0010. Therefore, the value of variable 'a' is 2, and when printed using printf, it will display 2.

    Rate this question:

  • 22. 

    Which constant can be expressed both in fractional and exponential forms?

    • Char

    • Void

    • Int

    • Float

    Correct Answer
    A. Float
    Explanation
    The constant "float" can be expressed both in fractional and exponential forms. In fractional form, it represents a decimal number with a fractional part, such as 3.14. In exponential form, it can be expressed as a number multiplied by a power of 10, such as 3.14 x 10^1. This flexibility allows for greater precision and a wider range of values compared to other data types like "char", "void", and "int".

    Rate this question:

  • 23. 

    Identify the valid variable name

    • Initial.Name

    • A+B

    • $ABC

    • Floats

    Correct Answer
    A. Floats
    Explanation
    The valid variable name in this case is "Floats". Variable names can consist of letters, numbers, and underscores, but they cannot start with a number or contain special characters like "+". "Initial.Name" is not a valid variable name because it contains a dot, which is not allowed. "$ABC" is also not a valid variable name because it starts with a special character. Therefore, the correct answer is "Floats".

    Rate this question:

  • 24. 

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

    • Char

    • Int

    • Float

    • Double

    Correct Answer
    A. Int
    Explanation
    The format identifier '%i' is commonly used for the int data type. This format specifier is used in C programming to display or read integer values. It is used with functions like printf() and scanf() to format the output or input of integer values.

    Rate this question:

  • 25. 

    In an assignment statement a=b; which of the following statement is true ?

    • The variable a and the variable b are same.

    • The value of b is assigned to variable a but if b changes later, it will not effect the value of variable a.

    • The value of b is assigned to variable a but if b changes later, it will effect the value of variable a

    • The value of variable a is assigned to variable b, and the value of variable b is asssigned to variable a.

    Correct Answer
    A. The value of b is assigned to variable a but if b changes later, it will not effect the value of variable a.
    Explanation
    The correct answer is that the value of b is assigned to variable a but if b changes later, it will not affect the value of variable a. This is because in an assignment statement, the value of the variable on the right side of the assignment operator (=) is assigned to the variable on the left side. However, any changes made to the variable on the right side after the assignment will not affect the value of the variable on the left side.

    Rate this question:

  • 26. 

    Which of the following is not a premitive data type in 'C' language?

    • Double

    • Array

    • Char

    • Float

    Correct Answer
    A. Array
    Explanation
    In the 'C' language, double, char, and float are all primitive data types. However, array is not a primitive data type in 'C'. An array is a collection of elements of the same data type, and it is considered a derived data type in 'C'.

    Rate this question:

  • 27. 

    Which operators are used to compare the values of operands to produce logical value in C language?

    • Logical operator

    • Relational operator

    • Assignment operator

    • None of the above

    Correct Answer
    A. Relational operator
    Explanation
    Relational operators are used to compare the values of operands in C language. These operators compare two values and return a logical value (true or false) based on the comparison. Examples of relational operators in C include equal to (==), not equal to (!=), greater than (>), less than (=), and less than or equal to (

    Rate this question:

  • 28. 

    An operator used to check a condition and select a value depending on the value of the condition is called

    • Logical operator

    • Decrement operator

    • Conditional or Ternary operator

    • Bitwise operator

    Correct Answer
    A. Conditional or Ternary operator
    Explanation
    The conditional or ternary operator is used to check a condition and select a value based on the result of that condition. It allows for concise and efficient code by providing a shorthand way to write if-else statements. The operator consists of a condition followed by a question mark, then a value to be returned if the condition is true, and a colon followed by a value to be returned if the condition is false. This operator is commonly used in programming languages like C, C++, and Java.

    Rate this question:

  • 29. 

    #define ISEQUAL(X, Y) X==Y void main(){ int X, Y; printf("%d", ISEQUAL(X,1));}

    • 2

    • 1

    • -1

    • 0

    Correct Answer
    A. 0
    Explanation
    The code defines a macro function ISEQUAL that takes two arguments X and Y and checks if X is equal to Y using the equality operator ==. In the main function, variables X and Y are declared. The printf statement prints the result of calling the ISEQUAL macro function with X as the first argument and 1 as the second argument. Since X is not initialized, its value is undefined, and the result of the comparison will be unpredictable. Therefore, the output could be any value, but it is most likely to be 0.

    Rate this question:

  • 30. 

    An external variable

    • Is globally accessible by all functions

    • Has a declaration

    • Will be initialized to 0 if not initialized

    • All of these

    Correct Answer
    A. All of these
    Explanation
    An external variable is a variable that is declared outside of any function and is accessible by all functions in a program. It has a global scope, meaning it can be accessed from anywhere in the program. If an external variable is not explicitly initialized, it will automatically be initialized to 0. Therefore, the correct answer is that an external variable is globally accessible by all functions, has a declaration, and will be initialized to 0 if not initialized.

    Rate this question:

  • 31. 

    Sizeof(long int) output will be … ?

    • 32

    • 4

    • 2

    • 1

    Correct Answer
    A. 32
    Explanation
    The correct answer is 32 because the sizeof() operator in C++ returns the size in bytes of the data type or variable specified. In this case, the data type is long int, which typically has a size of 4 bytes on most systems. Therefore, the output of sizeof(long int) will be 32 bits.

    Rate this question:

  • 32. 

    Which of the follwing is a ternary operator

    • :?

    • ?:

    • ??

    • ?::

    Correct Answer
    A. ?:
    Explanation
    The ternary operator is a conditional operator that takes three operands. It is represented by the symbol "?:". The first operand is a condition, the second operand is the value returned if the condition is true, and the third operand is the value returned if the condition is false. Therefore, the correct answer is ?: as it represents the ternary operator.

    Rate this question:

  • 33. 

    The result of a relational operator is always

    • Greater than or Less than

    • Greater Than or Equal to

    • True OR False

    • False OR False

    Correct Answer
    A. True OR False
    Explanation
    The result of a relational operator can be either true or false, depending on the comparison being made. For example, if we compare two numbers using the greater than operator, the result will be true if the first number is indeed greater than the second number, and false otherwise. Similarly, if we compare two strings using the equal to operator, the result will be true if the two strings are equal, and false otherwise. Therefore, the correct answer is "True OR False" because the result of a relational operator can be either true or false.

    Rate this question:

  • 34. 

    Int x=23, y; y= x--; printf("%d%d", x, y);

    • 22, 22

    • 23, 23

    • 22, 23

    • 23, 22

    Correct Answer
    A. 22, 23
    Explanation
    In this code snippet, the variable x is initially assigned the value 23. Then, the post-decrement operator (--) is used to decrement the value of x by 1. However, since the post-decrement operator is used, the value of x is first assigned to y and then decremented. Therefore, the value of y remains 23. Finally, the printf statement prints the values of x and y, which are 22 and 23 respectively.

    Rate this question:

  • 35. 

    The words if, else, auto, float etc. have predefined meaning and users cannot use them as variables. These words are called

    • Constant

    • Identifier

    • Keywords

    • Data types

    Correct Answer
    A. Keywords
    Explanation
    The words if, else, auto, float etc. have predefined meanings in programming languages and cannot be used as variables. They are reserved words that have specific functionalities within the language. These words are commonly referred to as keywords.

    Rate this question:

  • 36. 

    ? and : are called

    • Relational Operators

    • Conditional Operators

    • Logical Operators

    • Arithmetic Operators

    Correct Answer
    A. Conditional Operators
    Explanation
    The symbols "?" and ":" are called conditional operators because they are used to create conditional expressions in programming languages. These operators evaluate a condition and return one of two values based on the result of the condition. The "?" symbol is used to specify the condition, while the ":" symbol is used to separate the two possible values. This allows for concise and efficient coding of conditional statements.

    Rate this question:

  • 37. 

    Int a; a=5&&4; printf("%d", a);

    • 1

    • 0

    • Both A and B

    • None

    Correct Answer
    A. 1
    Explanation
    The expression "5 && 4" is a logical AND operation. In C programming, the logical AND operator (&&) returns true (1) if both operands are non-zero, and false (0) otherwise. Since both 5 and 4 are non-zero, the result of the logical AND operation is true (1). Therefore, the value of the variable "a" is 1. When we use the printf function to print the value of "a", it will output "1".

    Rate this question:

  • 38. 

    Algorithm should be

    • Precise

    • Unambiguous

    • Both

    • None

    Correct Answer
    A. Both
    Explanation
    The algorithm should be both precise and unambiguous. Being precise means that the algorithm should provide clear and specific instructions, leaving no room for interpretation. This ensures that the algorithm can be executed accurately and consistently. Being unambiguous means that the algorithm should have only one possible interpretation, eliminating any confusion or ambiguity in understanding the steps. By being both precise and unambiguous, the algorithm can be easily understood and implemented by both humans and computers.

    Rate this question:

  • 39. 

    Choose the correct option among which will be valid after this following statement #define PI 54.453

    • PI=3.141

    • Area = 3.2*PI

    • PI=PI+2

    • None of these

    Correct Answer
    A. Area = 3.2*PI
    Explanation
    After the statement "#define PI 54.453", the value of PI is defined as 54.453. Then, the statement "PI=3.141" attempts to reassign a new value to PI, which is not valid because PI is a constant defined using the #define directive. Therefore, the value of PI remains 54.453. The statement "area = 3.2*PI" calculates the area by multiplying 3.2 with the value of PI, which is 54.453. Hence, the correct option is "area = 3.2*PI".

    Rate this question:

  • 40. 

    Which of the following cannot be used as identifiers independely ?

    • Letters

    • Numbers

    • Spaces

    • Underscores

    Correct Answer
    A. Spaces
    Explanation
    Spaces cannot be used as identifiers independently because spaces are not allowed in variable or identifier names. In programming languages, spaces are used to separate different parts of a statement or expression. Therefore, using spaces as identifiers would result in a syntax error.

    Rate this question:

  • 41. 

    In the passage of text, individual words and punctuation marks are known as

    • Constant

    • Keywords

    • Delimiter

    • Operators

    Correct Answer
    A. Delimiter
    Explanation
    In the passage of text, individual words and punctuation marks are known as delimiters. Delimiters are used to separate or mark the boundaries between different elements in a text, such as words or sentences. They help to identify the structure and meaning of the text by indicating where one element ends and another begins. In this context, delimiters refer to both individual words and punctuation marks that serve this purpose.

    Rate this question:

  • 42. 

    Int main() {char a = 'a'; printf("%d", a); return 0;}

    • Compiler Error

    • A

    • 65

    • 97

    Correct Answer
    A. 97
    Explanation
    The given code snippet declares a variable 'a' of type char and assigns it the value 'a'. The printf statement is used to print the value of 'a' as an integer using the %d format specifier. In ASCII, the character 'a' has an integer value of 97. Therefore, the code will output 97.

    Rate this question:

  • 43. 

    The size of unsigned integer ?

    • 0 to 32767

    • 0 to 65536

    • -32,768 to +32,767

    • 0 to 256

    Correct Answer
    A. 0 to 65536
    Explanation
    The correct answer is "0 to 65536" because an unsigned integer can only hold positive values and zero. In this case, the range is from 0 to 65536, which includes all the possible values that can be represented by an unsigned integer.

    Rate this question:

  • 44. 

    A name start with letters or underscore is called

    • Keywords

    • Reserved keywords

    • Tokens

    • Identifiers

    Correct Answer
    A. Identifiers
    Explanation
    An identifier is a name that starts with letters or an underscore. It is used to identify variables, functions, classes, or any other user-defined item in a program. Identifiers cannot be the same as reserved keywords, which are predefined words with special meanings in the programming language. Tokens are the individual units of a program, including identifiers, keywords, operators, and literals. Therefore, the correct answer is identifiers.

    Rate this question:

  • 45. 

    Choose the correct statements

    • An identifier may start with an underscore

    • An identifier may end with an underscore

    • IF is a valid identifier

    • All of the above

    Correct Answer
    A. All of the above
    Explanation
    All of the given statements are correct. An identifier in programming is a name used to identify a variable, function, or any other user-defined item. It may start with an underscore, it may end with an underscore, and "IF" is a valid identifier. Identifiers in programming languages have certain rules and conventions, but these statements adhere to those rules and are therefore correct.

    Rate this question:

  • 46. 

    Int main() { printf("%d", 3>>1);

    • 3

    • 1

    • 2

    • 0

    Correct Answer
    A. 1
    Explanation
    The expression "3>>1" is a right shift operation in C. In this case, it means shifting the bits of the number 3 to the right by 1 position. Shifting a number to the right by 1 is equivalent to dividing it by 2. Therefore, the result of "3>>1" is 1.

    Rate this question:

  • 47. 

    Associativity of = operator is.

    • Left to right

    • Right to left

    • Assignement

    • All of the above

    Correct Answer
    A. Right to left
    Explanation
    The associativity of the = operator is right to left. This means that when there are multiple assignments in a single line of code, the rightmost assignment is evaluated first and then the result is assigned to the leftmost variable. For example, in the expression "a = b = c", the value of c is assigned to b first, and then the value of b is assigned to a.

    Rate this question:

  • 48. 

    Int main() { printf("%d", sizeof(long long double)); }

    • Error

    • 16

    • 6

    • Both (A) and (B)

    Correct Answer
    A. Error
    Explanation
    The code will produce an error because "long long double" is not a valid data type in C. It seems to be a combination of two different data types, "long long" and "double", which are not allowed to be combined in this way. Therefore, the code will not compile and an error will be thrown.

    Rate this question:

  • 49. 

    Int a; a=10

    • 5

    • 10

    • 20

    • 1

    Correct Answer
    A. 20
    Explanation
    The given code declares a variable 'a' and assigns it a value of 10. However, the value of 10 is not used or referenced in any way. The next line of code is 20, which means that the value 20 is the output or result of the code.

    Rate this question:

Quiz Review Timeline (Updated): May 3, 2024 +

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

  • Current Version
  • May 03, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 31, 2019
    Quiz Created by
    ABC
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.