C Programming Hardest Quiz Test!

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 Shaik Tasneem
S
Shaik Tasneem
Community Contributor
Quizzes Created: 1 | Total Attempts: 2,166
Questions: 37 | Attempts: 2,168

SettingsSettingsSettings
C Programming Hardest Quiz Test! - Quiz

This quiz is the C Programming Hardest Test that programming students should try and tackle before they sit for their certification exams. Do you feel like you have what it takes to tackle it based on what you have learned so far? How about you give it a try and see how well you will do?


Questions and Answers
  • 1. 

    What statement can print \n on screen?

    • A.

      Printf("\\n");

    • B.

      Printf("n\")

    • C.

      Printf('\\n')

    • D.

      Printf("\n")

    Correct Answer
    A. Printf("\\n");
    Explanation
    The correct answer is `printf("");`. This statement uses the `printf` function to print the string `""` on the screen. The backslash `\` is used to escape the forward slash `/` character, so it is printed as part of the string.

    Rate this question:

  • 2. 

    Pointers are variables that store addresses in memory. Which of the following statements best describes what a pointer variable represents?

    • A.

      An address in memory

    • B.

      A fixed value

    • C.

      A reference to a function

    • D.

      An integer representing memory locations

    Correct Answer
    A. An address in memory
    Explanation
    The address stored in a pointer variable is of type int because pointers store memory addresses, which are represented as integers.

    Rate this question:

  • 3. 

    What is the output of the following code?

    • A.

      11 11 11

    • B.

      Compile time error

    • C.

      Segmentation  fault/code trash

    • D.

      12 12 undefined value

    Correct Answer
    C. Segmentation  fault/code trash
    Explanation
    This error message typically occurs when a program tries to access memory that it doesn't have permission to access. In this specific case, the line foo(&p); is the culprit.

    Rate this question:

  • 4. 

    What will be printed? int a = 15;  int b = 0;  b = (a % 7);    printf("\n\n%i\n", b);

    • A.

      0

    • B.

      1

    • C.

      7

    • D.

      15

    Correct Answer
    B. 1
    Explanation
    The code calculates the remainder of dividing 15 by 7 using the modulus operator (%). Since the remainder is 1, the value of b will be 1. The printf statement will then print the value of b, which is 1.

    Rate this question:

  • 5. 

    The operators . , !! , < , = if arranged in ascending order of precedence reads?

    • A.

      .,!!,<,=

    • B.

      =,<,!!,.

    • C.

      =,!!,<,.

    • D.

      <,!!,=,.

    Correct Answer
    C. =,!!,<,.
    Explanation
    The answer =, !!,

    Rate this question:

  • 6. 

    Pain:Misery::?

    • A.

      Ignore::greet

    • B.

      Ignorance::confusion

    • C.

      Disease:poverty

    • D.

      Despair:lonliness

    Correct Answer
    D. Despair:lonliness
    Explanation
    "despair: loneliness" suggests that "despair" leads to "loneliness," which is a similar cause-and-effect relationship as "Pain: Misery."

    Rate this question:

  • 7. 

    A clock is so placed that at 12 noon its minutes hand points towards north-east, in which direction does its hour hand points at 1.30p.m?  

    • A.

      North

    • B.

      West

    • C.

      South 

    • D.

      East

    Correct Answer
    C. South 
    Explanation
    To determine the direction in which the hour hand points at 1:30 PM, given that the minute hand points towards the north-east at 12 noon, follow these steps:
    Understand the initial orientation:
    At 12 noon, the minute hand points north-east.
    The hour hand at 12 noon will point in the same direction as the minute hand, which is north-east.
    Determine the movement of the hour hand:
    Each hour represents a 30-degree movement of the hour hand (since the clock face is 360 degrees and there are 12 hours on a clock, 360 degrees / 12 hours = 30 degrees per hour).
    At 1:00 PM, the hour hand moves 30 degrees clockwise from its position at 12:00 noon.
    At 1:30 PM, the hour hand will move an additional 15 degrees (since 30 minutes is half of an hour, and 30 degrees / 2 = 15 degrees).
    Calculate the total movement from 12 noon to 1:30 PM:
    Total movement = 30 degrees (from 12:00 to 1:00) + 15 degrees (from 1:00 to 1:30) = 45 degrees.
    Determine the final direction:
    Since the initial direction at 12 noon is north-east, moving 45 degrees clockwise from north-east will point towards south.
    Therefore, at 1:30 PM, the hour hand will point towards the south.

    Rate this question:

  • 8. 

    Number of letters skipped in between adjacent letters in the series is in the order of 12 ,22,32 . which of the following series observes the above rule

    • A.

      CEJT

    • B.

      EGLO

    • C.

      EGLP

    • D.

      RTWZ

    Correct Answer
    A. CEJT
    Explanation
    The correct answer is CEJT because the number of letters skipped in between adjacent letters follows the pattern of increasing by 10 each time. In CEJT, the letters C and J have 12 letters skipped in between, while the letters J and T have 22 letters skipped in between. Therefore, the next letter in the series should have 32 letters skipped in between, which is consistent with the pattern observed in CEJT.

    Rate this question:

  • 9. 

    Which one of the four equations will be correct? given interchanges: signs "-" and "*" , numbers 3 and 6. 

    • A.

      6-3*2=9

    • B.

      6*3-4=15

    • C.

      3-6*8=10

    • D.

      3*6-4=33

    Correct Answer
    C. 3-6*8=10
  • 10. 

    In a row of 10 boys, when Rohith was shifted by 2 places towards the left he became 7th from the left end what was his earlier position from the right end of the row?

    • A.

      1

    • B.

      0

    • C.

      4

    • D.

      6

    Correct Answer
    B. 0
    Explanation
    Let's analyze the information given:

    1. Originally, Rohith was in a row of 10 boys.
    2. When Rohith was shifted by 2 places towards the left, he became the 7th from the left end.

    We can find Rohith's original position from the right end of the row using this information.

    Originally, there were 10 boys in the row, and Rohith became the 7th from the left end after shifting 2 places to the left. So, originally, he was the 10th boy from the left end.

    To find his original position from the right end, you can subtract his position from the total number of boys in the row:

    Position from the right end = Total number of boys - Position from the left end
    Position from the right end = 10 - 10
    Position from the right end = 0

    So, Rohith's earlier position from the right end of the row was 0 (he was the rightmost boy).

    Rate this question:

  • 11. 

    4,23,60,121,___?

    Correct Answer
    212
    Explanation
    The given sequence starts with 4 and each subsequent number is obtained by adding the square of the position of the number in the sequence. For example, 4 + 1^2 = 5, 23 + 2^2 = 27, 60 + 3^2 = 69, and so on. Therefore, the missing number in the sequence would be 121 + 4^2 = 121 + 16 = 137. However, this is not the given answer. It seems that the given answer of 212 does not follow the pattern of the sequence and is incorrect.

    Rate this question:

  • 12. 

    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Which letter should be 9th letter to the left of 9th letter from the right if the first half of the given alphabets is reversed

    • A.

    • B.

      E

    • C.

      F

    • D.

      I

    Correct Answer
    B. E
    Explanation
    If the first half of the given alphabets is reversed, the sequence becomes M L K J I H G F E D C B A N O P Q R S T U V W X Y Z. Counting 9 letters from the right, we reach the letter R. Counting 9 letters to the left of R, we reach the letter E. Therefore, the letter E should be the 9th letter to the left of the 9th letter from the right.

    Rate this question:

  • 13. 

    Umbrella is to rain what goggles are to?

    • A.

      Light 

    • B.

      Glare

    • C.

      Sun

    • D.

      Beam

    Correct Answer
    C. Sun
    Explanation
    Just as an umbrella is used as protection from rain, goggles or sunglasses are used as protection from the sun and its intense light and glare. This analogy highlights the protective function of goggles in response to the sun, making option C, "sun," the correct choice.

    Rate this question:

  • 14. 

    Odd man out.

    • A.

      Billiards

    • B.

      Basketball

    • C.

      Snookers

    • D.

      Table tennis

    Correct Answer
    B. Basketball
    Explanation
    The odd man out in this group is basketball because it is the only sport that is played with a round ball, while the other three sports (billiards, snookers, and table tennis) are played with balls that are not round.

    Rate this question:

  • 15. 

    According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments?

    • A.

      Int main(int argc,char *argv[])

    • B.

      Int main(){int argc ; char *argv);

    • C.

      None

    • D.

      Int main {argc,argv)int argc; char *argv;

    Correct Answer
    A. Int main(int argc,char *argv[])
    Explanation
    The correct way of declaring main when it receives command-line arguments is "int main(int argc,char *argv[])". This declaration follows the ANSI specifications, where "argc" represents the number of command-line arguments passed to the program, and "argv" is an array of strings containing the actual arguments. This declaration allows the program to access and process the command-line arguments effectively.

    Rate this question:

  • 16. 

    Char *s[10] defines an array of ___________

    • A.

      None

    • B.

      String to pointer 

    • C.

      Pointers to strings

    • D.

      Both pointers to string and strings to pointers

    Correct Answer
    C. Pointers to strings
    Explanation
    The declaration "char *s[10]" defines an array of pointers to strings. Each element in the array "s" is a pointer that can point to a string. The size of the array is 10, meaning it can hold 10 pointers to strings.

    Rate this question:

  • 17. 

    Which header file should be included to use functions like malloc() and calloc()?

    • A.

      Dos.h

    • B.

      Alloc.h

    • C.

      Stdlib.h

    • D.

      Memory.h

    Correct Answer
    C. Stdlib.h
    Explanation
    To use functions like malloc() and calloc(), the header file that should be included is stdlib.h. This header file contains the declarations for various standard library functions, including memory allocation functions like malloc() and calloc(). By including this header file, the program can access these functions and use them for dynamic memory allocation.

    Rate this question:

  • 18. 

    What gets printed? printf("%d\n",4 ?:8);

    • A.

      8

    • B.

      4

    • C.

      Null

    • D.

      Compiler error

    Correct Answer
    D. Compiler error
    Explanation
    The code will result in a compiler error because the conditional operator (?:) requires three operands: a condition, a value if the condition is true, and a value if the condition is false. In this case, there is no condition provided before the question mark, resulting in a syntax error.

    Rate this question:

  • 19. 

    1   11   21   1211 111221   ________

    • A.

      213211

    • B.

      312211

    • C.

      122311

    • D.

      312221

    Correct Answer
    B. 312211
    Explanation
    The given sequence follows a pattern where each number describes the count of consecutive digits in the previous number. Starting with 1, there is 1 digit, so the next number is 11. In 11, there are 2 consecutive digits, so the next number is 21. In 21, there is 1 digit followed by 1 digit, so the next number is 1211. Continuing this pattern, the next number would be 312211, where there are 3 ones, followed by 2 twos, followed by 1 one.

    Rate this question:

  • 20. 

    Which keyword is used for coming out of recursion?

    • A.

      Break 

    • B.

      Return

    • C.

      Exit

    • D.

      All the above

    • E.

      Continue

    Correct Answer
    B. Return
    Explanation
    The keyword "return" is used for coming out of recursion. In a recursive function, when a condition is met, the function can return a value and terminate the current call, allowing the program flow to return to the previous call. This is essential to prevent infinite recursion and to ensure that the function completes its task and returns the desired result. The "return" keyword allows the function to pass control back to the calling function and exit the recursion.

    Rate this question:

  • 21. 

    What is the output of the following?

    • A.

      Yes 

    • B.

      No

    • C.

      Compile time error

    • D.

      Yes no

    Correct Answer
    C. Compile time error
    Explanation
    The given code does not provide any context or code logic to suggest what the expected output should be. However, based on the given options, it is likely that the code would result in a compile time error. This could be due to various reasons such as missing semicolons, incorrect syntax, or undefined variables. Without further information, it is not possible to determine the exact reason for the compile time error.

    Rate this question:

  • 22. 

    How many tokens are there in the following?       if(csi==100);

    • A.

      6

    • B.

      7

    • C.

      5

    • D.

      4

    Correct Answer
    B. 7
    Explanation
    The given code snippet contains 7 tokens. The tokens are: "if", "(", "csi", "==", "100", ")", and ";".

    Rate this question:

  • 23. 

    C programming:the given expression P-=Q+1 is same as

    • A.

      P=P-Q-1

    • B.

      P=P-Q+1

    • C.

      P=-P+Q+1

    • D.

      NONE

    Correct Answer
    A. P=P-Q-1
    Explanation
    The given expression P-=Q+1 is the same as P=P-Q-1. The "-=" operator is used to subtract the value on the right-hand side from the variable on the left-hand side and assign the result back to the variable. Therefore, P-=Q+1 is equivalent to P=P-(Q+1), which simplifies to P=P-Q-1.

    Rate this question:

  • 24. 

    A pointer is a C which has not been initialized is know as:

    • A.

      Far pointer

    • B.

      Void pointer

    • C.

      Null pointer

    • D.

      Wild pointer

    Correct Answer
    D. Wild pointer
    Explanation
    A wild pointer is a pointer in C that has not been initialized or assigned a valid memory address. It points to a random or unpredictable memory location, which can result in unexpected behavior or program crashes when accessed.

    Rate this question:

  • 25. 

    Which of the following does not represent a valid storage class in C?

    • A.

      Static

    • B.

      Union

    • C.

      Extern

    • D.

      Automatic

    Correct Answer
    B. Union
    Explanation
    In C, static, extern, and automatic are valid storage classes. However, union is not a storage class in C. It is a data type that allows storing different types of data in the same memory location. Therefore, union does not represent a valid storage class in C.

    Rate this question:

  • 26. 

    When fopen() is not able to open a file, then it returns

    • A.

      Compiler dependent

    • B.

      Runtime error

    • C.

      EOF

    • D.

      NULL

    Correct Answer
    A. Compiler dependent
    Explanation
    The return value of fopen() when it is not able to open a file is compiler dependent, meaning it can vary depending on the compiler being used. Different compilers may handle this situation differently, so the specific return value cannot be determined universally.

    Rate this question:

  • 27. 

    How will you free the allocated memory?

    • A.

      Delete(var-name);

    • B.

      Free(var-name);

    • C.

      Remove(var-name)

    • D.

      Dealloc(var-name);

    Correct Answer
    B. Free(var-name);
    Explanation
    The correct answer is "free(var-name)". This is because the "free()" function is used in C programming to deallocate the memory that was previously allocated using functions like "malloc()" or "calloc()". By using "free(var-name)", the memory allocated to the variable "var-name" will be released and made available for other uses.

    Rate this question:

  • 28. 

    What will be x in the following c code? #include void main() {  int x; }

    • A.

      Integer variable

    • B.

      Static variable

    • C.

      Registered variable

    • D.

      Global variable

    Correct Answer
    A. Integer variable
    Explanation
    In the given C code, x is an integer variable that has been declared but not initialized. Its value is indeterminate and could be anything, as it will contain whatever data was previously at that memory location. It’s generally a good practice to initialize variables when you declare them to avoid any unexpected behavior. For example, you could modify the code to int x = 0; to initialize x with a value of 0.

    Rate this question:

  • 29. 

    Which of the following cannot be static in C?

    • A.

      Variables 

    • B.

      Structures

    • C.

      Functions

    • D.

      None

    Correct Answer
    D. None
    Explanation
    All of the options - variables, structures, and functions - can be declared as static in C. The "none" option implies that there is no element in the given list that cannot be static. Therefore, the correct answer is "none".

    Rate this question:

  • 30. 

    What is the output of the following?   #include int main() {     char ch;     if(ch = printf(""))         printf("It matters\n");     else         printf("It doesn't matters\n");     return 0; }

    • A.

       It matters

    • B.

      It doesn’t matters

    • C.

       Run time error

    • D.

      Nothing

    Correct Answer
    B. It doesn’t matters
    Explanation
    The output of the code is "It doesn't matters". This is because the if statement is checking the result of the printf function, which is the number of characters printed. Since the printf function is given an empty string as an argument, it doesn't print anything and returns 0. Therefore, the condition in the if statement is false and the else block is executed, resulting in the output "It doesn't matters".

    Rate this question:

  • 31. 

    How many times is Hello world printed ?   int main() {     fork();     fork();     printf("Hello world\n"); }

    • A.

      1

    • B.

      2

    • C.

      4

    • D.

      8

    Correct Answer
    C. 4
    Explanation
    The correct answer is 4 because there are two fork() calls in the code. Each fork() call creates a new process, so the code will be executed by a total of 4 processes. Each process will print "Hello world" once, resulting in a total of 4 "Hello world" prints.

    Rate this question:

  • 32. 

     What is the output of this C code?   void main() {     int i, j;     for(i=0,j=0;i<10,j<20;i++,j++){         printf("i=%d \t j=%d\n", i, j);     } }

    • A.

      Print i and j till 19

    • B.

      Print i till 9 and j till 19

    • C.

      Print i and j till 9

    • D.

      Runtime error

    Correct Answer
    A. Print i and j till 19
    Explanation
    The given code contains a for loop that iterates as long as i is less than 10 and j is less than 20. Inside the loop, the values of i and j are printed. Since both i and j start from 0 and increment by 1 in each iteration, the loop will execute 10 times and print the values of i and j from 0 to 9 and 0 to 19 respectively. Therefore, the output of the code will be to print i and j till 19.

    Rate this question:

  • 33. 

    What is the output of this C code? #include int main() {     int y = 2;     int z = y +(y = 10);     printf("%d\n", z); }

    • A.

      2

    • B.

      4

    • C.

      20

    • D.

      Compile time error

    Correct Answer
    C. 20
    Explanation
    The code snippet assigns the value of 2 to the variable y and then adds the value of y (which is 2) to the value of y (which is 10 after the assignment). This results in z being assigned the value of 12. However, the printf statement prints the value of z, which is 12. Therefore, the output of the code is 12.

    Rate this question:

  • 34. 

    Which of the following is not a standard C Library?

    • A.

      Errno.h

    • B.

      Setjmp.h

    • C.

      Signal.h

    • D.

      Retarg.h

    Correct Answer
    D. Retarg.h
    Explanation
    The standard C Library provides a set of functions and headers that are commonly used in C programming. The headers errno.h, setjmp.h, and signal.h are all part of the standard C Library. However, retarg.h is not a standard C Library header.

    Rate this question:

  • 35. 

    Which one of the following is not a prime number?

    • A.

      31

    • B.

      61

    • C.

      71

    • D.

      91

    Correct Answer
    D. 91
    Explanation
    A prime number is a number that is only divisible by 1 and itself. Among the given options, 91 is not a prime number because it is divisible by 7 and 13 in addition to 1 and 91. Therefore, 91 is the correct answer as it does not meet the criteria of being a prime number.

    Rate this question:

  • 36. 

    If one-third of one-fourth of a number is 15, then three-tenth of that number is:

    • A.

      35

    • B.

      36

    • C.

      45

    • D.

      54

    Correct Answer
    D. 54
    Explanation
    If one-third of one-fourth of a number is 15, it means that one-fourth of the number is 45 (since 15 multiplied by 3 is 45). To find three-tenths of that number, we multiply 45 by 3 and divide by 10. This gives us 135 divided by 10, which equals 13.5. However, since the options only include whole numbers, we round up to the nearest whole number, which is 14. Therefore, the correct answer is 54.

    Rate this question:

  • 37. 

    Which of the following is a prime number ?

    • A.

      33

    • B.

      81

    • C.

      93

    • D.

      97

    Correct Answer
    D. 97
    Explanation
    97 is a prime number because it is only divisible by 1 and itself. It does not have any other factors.

    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
  • Jul 04, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 28, 2019
    Quiz Created by
    Shaik Tasneem
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.