Programming Basics Of C Language - Quiz 1 ( 6-7 June 2018 )

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 Nchaudhuri31
N
Nchaudhuri31
Community Contributor
Quizzes Created: 19 | Total Attempts: 9,115
Questions: 30 | Attempts: 311

SettingsSettingsSettings
Programming Quizzes & Trivia

Dear Student,
The Quiz consists of General MCQ on C Programming Language.
Total 30 Questions
Time Allocated : 20 Minutes
.
Happy Learning !
Team SHIVAM


Questions and Answers
  • 1. 

    The return-type of “printf” is:

    • A.

      Void

    • B.

      Float

    • C.

      Int

    • D.

      Char

    Correct Answer
    C. Int
    Explanation
    The return-type of "printf" is "int" because "printf" is a function in the C programming language that is used to print formatted output. It returns the number of characters successfully written to the output or a negative value if an error occurs. Therefore, the return-type is "int" to indicate the number of characters printed.

    Rate this question:

  • 2. 

    The token ‘sizeof’ is

    • A.

      Operator

    • B.

      Function

    • C.

      Structure

    • D.

      Modifier

    Correct Answer
    A. Operator
    Explanation
    The token 'sizeof' is an operator in C and C++ programming languages. It is used to determine the size in bytes of a data type or a variable. It returns the size as an unsigned integer value. This operator is often used in memory allocation and manipulation operations to ensure the correct amount of memory is allocated or accessed.

    Rate this question:

  • 3. 

    The function that calls itself is referred to as:

    • A.

      Iterative

    • B.

      Recursive

    • C.

      Nested

    • D.

      None of the above

    Correct Answer
    B. Recursive
    Explanation
    A function that calls itself is referred to as recursive. This means that the function is able to repeatedly call itself within its own code, allowing for repeated execution of a specific set of instructions. This recursive behavior is often used to solve problems that can be divided into smaller subproblems, as the function can call itself with smaller inputs until a base case is reached. This allows for a more elegant and concise solution to certain types of problems.

    Rate this question:

  • 4. 

    The following escape sequence represents a carriage return:

    • A.

      “\n”

    • B.

      “\r”

    • C.

      “\t”

    • D.

      “\b”

    Correct Answer
    B. “\r”
    Explanation
    The escape sequence "\r" represents a carriage return. When this sequence is encountered in a string, it causes the cursor to move to the beginning of the current line, effectively returning the cursor to the start of the line. This is commonly used in programming to overwrite or update text on the same line, or to create a new line of text without moving to the next line.

    Rate this question:

  • 5. 

    The conversion character corresponding to long integer is

    • A.

      “%u”

    • B.

      “%i”

    • C.

      “%d”

    • D.

      “%ld”

    Correct Answer
    A. “%u”
    Explanation
    The conversion character "%u" is used to represent an unsigned long integer in C programming. It is used to print the value of an unsigned long integer variable. The "%u" conversion character is specifically used for unsigned integers, while "%d" and "%ld" are used for signed integers. Therefore, the correct answer is "%u" for representing a long integer.

    Rate this question:

  • 6. 

    Linking during compilation means to connect:

    • A.

      User defined function header

    • B.

      User defined function code

    • C.

      Library function code

    • D.

      Library function header

    Correct Answer
    C. Library function code
    Explanation
    Linking during compilation means to connect library function code. When a program is compiled, it may call functions that are defined in external libraries. The linking process is responsible for connecting the function calls in the program to the actual code in the library. This allows the program to access and execute the library functions when needed. Therefore, the correct answer is library function code.

    Rate this question:

  • 7. 

    ‘enum’ is a

    • A.

      Basic datatype

    • B.

      Derived datatype

    • C.

      User defined datatype

    • D.

      Modifier

    Correct Answer
    C. User defined datatype
    Explanation
    The correct answer is "user defined datatype" because the keyword "enum" is used to define a set of named constants. It allows us to create a custom data type with a fixed set of values, which can be used in variables and functions. This means that "enum" is not a basic or derived datatype, nor a modifier, but rather a way to define our own data type.

    Rate this question:

  • 8. 

    The maximum size of the member is the size of which of the following token

    • A.

      structure

    • B.

      Union

    • C.

      Class

    • D.

      Enumeration

    Correct Answer
    A. structure
    Explanation
    The maximum size of the member is determined by the size of the structure. In a structure, each member has its own memory space allocated, and the size of the structure is determined by the sum of the sizes of its members. Therefore, the maximum size of the member is limited by the size of the structure itself.

    Rate this question:

  • 9. 

    In Pre-processor is taken into consideration by the compiler during

    • A.

      Pre-compilation

    • B.

      Compilation

    • C.

      Linking

    • D.

      Execution

    Correct Answer
    A. Pre-compilation
    Explanation
    The pre-processor is a part of the compiler that processes directives before the actual compilation process begins. It handles tasks such as including header files, macro expansion, and conditional compilation. Therefore, the pre-processor is taken into consideration by the compiler during pre-compilation.

    Rate this question:

  • 10. 

    In procedure oriented programming , the emphasis is on:

    • A.

      Structure

    • B.

      Data

    • C.

      object

    • D.

      function

    Correct Answer
    D. function
    Explanation
    In procedure-oriented programming, the emphasis is on functions. This means that the program is divided into a set of procedures or functions that perform specific tasks. Each function is responsible for a specific operation and can be called from other parts of the program. The focus is on breaking down the program into smaller, manageable units of code, making it easier to understand and maintain. Functions allow for code reuse and modular programming, promoting efficiency and organization in the program.

    Rate this question:

  • 11. 

    Which of the following is not a valid variable name declaration?

    • A.

      Int _a3;

    • B.

      Int a_3;

    • C.

      Int 3_a;

    • D.

      Int _3a

    Correct Answer
    C. Int 3_a;
    Explanation
    The variable name "3_a" is not a valid variable name declaration because it starts with a number. In programming, variable names cannot start with a number, they must start with a letter or an underscore.

    Rate this question:

  • 12. 

    Variable name resolving (number of significant characters for uniqueness of variable) depends on

    • A.

      Compiler and linker implementations

    • B.

      Assemblers and loaders implementations

    • C.

      C language

    • D.

      None of these

    Correct Answer
    A. Compiler and linker implementations
    Explanation
    The correct answer is Compiler and linker implementations. Variable name resolving, specifically the number of significant characters required for uniqueness of a variable, is determined by the way the compiler and linker are implemented. These tools are responsible for translating and linking the code, and they have their own rules and limitations for variable naming. Assemblers and loaders are not directly involved in the process of variable name resolving, so they do not affect the number of significant characters needed for uniqueness.

    Rate this question:

  • 13. 

    Which is valid C expression?

    • A.

      Int my_num = 100,000;

    • B.

      Int my_num = 100000;

    • C.

      Int my num = 1000;

    • D.

      Int $my_num = 10000;

    Correct Answer
    B. Int my_num = 100000;
    Explanation
    The correct answer is "int my_num = 100000;". This is a valid C expression because it follows the syntax rules for declaring and initializing a variable in C. The variable "my_num" is declared as an integer and assigned the value 100000.

    Rate this question:

  • 14. 

    What will happen if the below program is executed? #include int main() { int main = 3; printf("%d", main); return 0; }

    • A.

      Compile-time error

    • B.

      run-time error

    • C.

      Prints 3

    • D.

      Halt after the “printf” statement

    Correct Answer
    C. Prints 3
    Explanation
    The program will print 3. This is because the variable "main" is redefined as an integer with the value of 3. When the printf statement is executed, it will print the value of the variable "main", which is 3.

    Rate this question:

  • 15. 

    Which of the following cannot be a variable name in C?

    • A.

      Volatile

    • B.

      True

    • C.

      Friend

    • D.

      Export

    Correct Answer
    A. Volatile
    Explanation
    In C, "volatile" is a keyword that is used to indicate that a variable's value can be changed by external factors, such as hardware or other threads. Therefore, "volatile" cannot be used as a variable name because it is a reserved keyword in the language.

    Rate this question:

  • 16. 

    Comment on the output of this C code? #include int main() { float f1 = 0.1; if (f1 == 0.1) printf("equal\n"); else printf("not equal\n"); return 0; }

    • A.

      Equal

    • B.

      Not equal

    • C.

      Output depends on compiler

    • D.

      Code will not compile

    Correct Answer
    B. Not equal
    Explanation
    The output of this code is "not equal". This is because floating-point numbers cannot be represented exactly in binary, leading to small rounding errors. In this case, the value 0.1 cannot be represented exactly in binary, so when it is assigned to the variable f1, it is rounded to the nearest representable value. When comparing f1 to the value 0.1, the two values are not exactly equal due to this rounding error, so the code prints "not equal".

    Rate this question:

  • 17. 

    Comment on the output of this C code? #include int main() { int a[5] = {1, 2, 3, 4, 5}; int i; for (i = 0; i < 5; i++) if ((char)a[i] == '5') printf("%d\n", a[i]); else printf("FAIL\n"); return 0; }

    • A.

      The compiler will flag an error

    • B.

      Program will compile and print 5

    • C.

      Program will print the ASCII value of 5

    • D.

      Program will print FAIL for 5 times

    Correct Answer
    D. Program will print FAIL for 5 times
    Explanation
    The given code will print "FAIL" for 5 times. This is because the code is comparing the ASCII value of the elements in the array with the ASCII value of '5'. Since the ASCII value of '5' is 53, which is not equal to any of the elements in the array (1, 2, 3, 4, 5), the code will enter the else statement and print "FAIL" for each iteration of the loop.

    Rate this question:

  • 18. 

    What is the output of this C code (on a 32-bit compiler)? #include int main() { int x = 10000; double y = 56; int *p = &x; double *q = &y; printf("p and q are %d and %d", sizeof(p), sizeof(q)); return 0; }

    • A.

      P and q are 4 and 4

    • B.

      P and q are 4 and 8

    • C.

      Compiler error

    • D.

      p and q are 2 and 8

    Correct Answer
    A. P and q are 4 and 4
    Explanation
    The output of this C code is "p and q are 4 and 4". The sizeof(p) and sizeof(q) statements return the size in bytes of the variables p and q respectively. In a 32-bit compiler, the size of an integer pointer (p) and a double pointer (q) is 4 bytes each. Therefore, when the printf statement is executed, it prints "p and q are 4 and 4".

    Rate this question:

  • 19. 

    What is the output of the following C code(on a 64 bit machine)? #include union Sti { int nu; char m; }; int main() { union Sti s; printf("%d", sizeof(s)); return 0; }

    • A.

      8

    • B.

      5

    • C.

      9

    • D.

      4

    Correct Answer
    D. 4
    Explanation
    The output of the given code is 4.

    The code defines a union named "Sti" which has two members: an integer "nu" and a character "m". The size of a union is determined by the size of its largest member. In this case, the size of the integer "nu" is 4 bytes on a 64-bit machine, so the size of the union is also 4 bytes.

    The printf statement then prints the size of the union, which is 4.

    Rate this question:

  • 20. 

    What is the output of this C code? #include int main() { float x = 'a'; printf("%f", x); return 0; }

    • A.

      A

    • B.

      Run time error

    • C.

      A.0000000

    • D.

      97.000000

    Correct Answer
    D. 97.000000
    Explanation
    The code initializes a float variable x with the ASCII value of the character 'a', which is 97. The printf statement then prints the value of x as a float, resulting in the output 97.000000.

    Rate this question:

  • 21. 

    What is the output of this program? void main() { int a=b=c=10; a=b=c=50; printf(“\n %d %d %d”,a,b,c); }

    • A.

      50 50 50

    • B.

      Compile Time Error

    • C.

      10 10 10

    • D.

      Three Garbage Values

    Correct Answer
    B. Compile Time Error
    Explanation
    The program will result in a compile-time error. This is because the variables a, b, and c are not declared before being assigned values. In C, variables must be declared before they can be used. Therefore, the program will not compile successfully.

    Rate this question:

  • 22. 

    By default a function returns a value of type

    • A.

      Int

    • B.

      Char

    • C.

      Void

    • D.

      None of these

    Correct Answer
    A. Int
    Explanation
    By default, a function returns a value of type int. This means that if a function does not have a return type specified, it will assume the return type to be int. The int data type is used to represent integer values, such as whole numbers.

    Rate this question:

  • 23. 

    Which is not keyword in ‘C’ ?

    • A.

      Typedef

    • B.

      Const

    • C.

      Near

    • D.

      Complex

    Correct Answer
    D. Complex
    Explanation
    The keyword "complex" is not a keyword in the C programming language. The other options, typedef, const, and near, are all keywords in C.

    Rate this question:

  • 24. 

    Which is valid string function?

    • A.

      Strpbrk

    • B.

      Strlen

    • C.

      Strxfrm

    • D.

      Strcut

    Correct Answer
    B. Strlen
    Explanation
    strlen is a valid string function. It is used to determine the length of a string, i.e., the number of characters in the string. It returns an integer value representing the length of the string.

    Rate this question:

  • 25. 

    What will be output if you will compile and execute the following c code? #include "stdio.h" #include "string.h" void main() { int i=0; for(;i

    • A.

      0 1 2

    • B.

      0 1 2 3

    • C.

      1 2 3

    • D.

      Compilation error

    • E.

      Infinite loop

    Correct Answer
    C. 1 2 3
    Explanation
    The code snippet provided includes a for loop that iterates from 0 to a certain condition. In this case, the condition is "i 0", which is not a valid condition and will result in a compilation error. Therefore, the correct answer is "Compilation error".

    Rate this question:

  • 26. 

    Number of bytes required for double is

    • A.

      2

    • B.

      4

    • C.

      6

    • D.

      8

    Correct Answer
    D. 8
    Explanation
    The number of bytes required for a double data type is 8. In most programming languages, a double is a floating-point data type that is used to represent decimal numbers with a higher precision compared to a float data type. The 8 bytes of memory allocated for a double allows it to store a wider range of values with greater precision.

    Rate this question:

  • 27. 

    What is the output of this program? void main() { int i=5; while(i!=65) i++; while(i

    • A.

      97

    • B.

      A

    • C.

      A

    • D.

      B

    Correct Answer
    D. B
    Explanation
    The program starts with initializing the variable i to 5. It then enters a while loop that increments the value of i by 1 until i becomes 65. After that, it enters another while loop that checks if i is less than 97. Since 65 is not less than 97, the loop is not executed. Therefore, the output of the program is b.

    Rate this question:

  • 28. 

    What is the output of this program? void main() { int i=100; while(i

    • A.

      100

    • B.

      101

    • C.

      I

    • D.

      No output

    Correct Answer
    D. No output
    Explanation
    The program does not have any output because there is no code inside the main function that prints anything to the console. The variable i is initialized to 100, but there is no code to manipulate or print its value. Therefore, the program does not produce any output.

    Rate this question:

  • 29. 

    What is the output of this program? void main() { int i,j; for(i=0,j=5; i

    • A.

      51423

    • B.

      Error

    • C.

      Infinite loop

    • D.

      No Output

    Correct Answer
    C. Infinite loop
    Explanation
    The given program is an infinite loop because the condition in the for loop (i < j) is always true. The loop will continue indefinitely, incrementing the value of i and decrementing the value of j, but since there is no condition that will make the loop terminate, it will keep running forever. Therefore, the output of this program is an infinite loop.

    Rate this question:

  • 30. 

    C programs are converted into machine language with the help of

    • A.

      An Editor

    • B.

      An Operating System

    • C.

      A Compiler

    • D.

      An Interpreter

    • E.

      None of these

    Correct Answer
    C. A Compiler
    Explanation
    C programs are converted into machine language with the help of a compiler. A compiler is a software tool that translates the high-level source code written in a programming language like C into machine code that can be understood and executed by the computer's processor. It performs various tasks such as lexical analysis, syntax analysis, semantic analysis, and code generation to convert the source code into machine language instructions.

    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
  • Jun 03, 2018
    Quiz Created by
    Nchaudhuri31
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.