C Programming Hardest Quiz Test!

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 Shaik Tasneem
S
Shaik Tasneem
Community Contributor
Quizzes Created: 1 | Total Attempts: 2,621
| Attempts: 2,621 | Questions: 37
Please wait...
Question 1 / 37
0 %
0/100
Score 0/100
1. Which of the following is a prime number ?

Explanation

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

Submit
Please wait...
About This Quiz
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... see morehave 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? see less

2. How will you free the allocated memory?

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.

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

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.

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

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.

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

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.

Submit
6. Char *s[10] defines an array of ___________

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.

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

Explanation

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

Submit
8. Which one of the following is not a prime number?

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.

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

Explanation

not-available-via-ai

Submit
10. Odd man out.

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.

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

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.

Submit
12. 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

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.

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

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.

Submit
14. 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

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.

Submit
15. What statement can print \n on screen?

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.

Submit
16. 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?  

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.

Submit
17. What is the output of the following code?

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.

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

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.

Submit
19. 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?

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

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

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.

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

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.

Submit
22. Which of the following cannot be static in C?

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

Submit
23. What is the output of the following?

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.

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

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.

Submit
25. 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;
}

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

Submit
26. Which keyword is used for coming out of recursion?

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.

Submit
27. Which of the following is not a standard C Library?

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.

Submit
28. Pain:Misery::?

Explanation

"despair: loneliness" suggests that "despair" leads to "loneliness," which is a similar cause-and-effect relationship as "Pain: Misery."

Submit
29. 4,23,60,121,___?

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.

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

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.

Submit
31. Umbrella is to rain what goggles are to?

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.

Submit
32. 1   11   21   1211 111221   ________

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.

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

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.

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

Explanation

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

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

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.

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

Explanation

The answer =, !!,

Submit
37.  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);
    }
}

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.

Submit
View My Results

Quiz Review Timeline (Updated): Jul 4, 2024 +

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
Cancel
  • All
    All (37)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following is a prime number ?
How will you free the allocated memory?
According to ANSI specifications which is the correct way of declaring...
What will be printed? ...
Which header file should be included to use functions like malloc()...
Char *s[10] defines an array of ___________
Pointers are variables that store addresses in memory. Which of the...
Which one of the following is not a prime number?
Which one of the four equations will be correct?...
Odd man out.
What gets printed? printf("%d\n",4 ?:8);
Number of letters skipped in between adjacent letters in the series is...
What will be x in the following c code? ...
A B C D E F G H I J K L M...
What statement can print \n on screen?
A clock is so placed that at 12 noon its minutes hand points towards...
What is the output of the following code?
Which of the following does not represent a valid storage class in C?
In a row of 10 boys, when Rohith was shifted by 2 places towards the...
If one-third of one-fourth of a number is 15, then three-tenth of that...
What is the output of this C code?...
Which of the following cannot be static in C?
What is the output of the following?
C programming:the given expression P-=Q+1 is same as
What is the output of the following?...
Which keyword is used for coming out of recursion?
Which of the following is not a standard C Library?
Pain:Misery::?
4,23,60,121,___?
How many times is Hello world printed ?...
Umbrella is to rain what goggles are to?
1   11   21   1211 111221   ________
A pointer is a C which has not been initialized is know as:
How many tokens are there in the...
When fopen() is not able to open a file, then it returns
The operators . , !! , < , = if arranged in ascending order of...
 What is the output of this C code?...
Alert!

Advertisement