Blind Coding C Programming Quiz!

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 Nishad
N
Nishad
Community Contributor
Quizzes Created: 1 | Total Attempts: 1,566
| Attempts: 1,566 | Questions: 50
Please wait...
Question 1 / 50
0 %
0/100
Score 0/100
1.  Which of the following is not an arithmetic operation?  

Explanation

The expression "a != 10" is not an arithmetic operation because it is a comparison operation. The "!=" operator checks if the value of "a" is not equal to 10. Arithmetic operations involve mathematical calculations such as addition, subtraction, multiplication, and division. In this case, the other expressions "a *= 10", "a /= 10", and "a %= 10" involve multiplication, division, and modulus operations respectively, making them arithmetic operations.

Submit
Please wait...
About This Quiz
Blind Coding C Programming Quiz! - Quiz

Blind Coding C Programming Quiz tests knowledge of C syntax, control structures, and memory management. It evaluates understanding of ASCII values, conditional operators, function behavior, and array size calculation, enhancing essential C programming skills.

Personalize your quiz and earn a certificate with your name on it!
2. The precedence of arithmetic operators is (from highest to lowest)

Explanation

The precedence of arithmetic operators determines the order in which mathematical operations are performed. In this case, the correct answer is "%, *, /, +, –". This means that the modulus operator (%) has the highest precedence, followed by multiplication (*), division (/), addition (+), and subtraction (-). This order ensures that calculations involving these operators are performed correctly according to mathematical conventions.

Submit
3. What will be the output of the program ? #include int main() {     float arr[] = {12.4, 2.3, 4.5, 6.7};     printf("%d\n", sizeof(arr)/sizeof(arr[0]));     return 0; }  

Explanation

The program calculates the size of the array by dividing the total size of the array (sizeof(arr)) by the size of each element in the array (sizeof(arr[0])). Since the array is declared as a float array, the size of each element is 4 bytes. Therefore, the output of the program will be 4, indicating that there are 4 elements in the array.

Submit
4. The library function used to reverse a string is ____ 

Explanation

The correct answer is strrev(). This is because the strrev() function is a library function that is used to reverse a string. It takes a string as input and returns the reversed string as output.

Submit
5.  If a function contains two return statements successively, the compiler will generate warnings. Yes/No?

Explanation

When a function contains two return statements successively, it means that both return statements are executed one after the other. This can lead to a situation where only the first return statement is actually reached and the second return statement is never executed. The compiler generates warnings in such cases because it indicates a potential logic error in the code. It is generally considered good practice to have only one return statement in a function to ensure clarity and avoid confusion.

Submit
6. We can modify the pointers "source" as well as "target".  

Explanation

The given statement is true because it states that we have the ability to modify the pointers "source" and "target". This implies that we can change the values or addresses that these pointers are pointing to. Therefore, the correct answer is true.

Submit
7. Which of the following operators has the lowest precedence?

Explanation

The operator with the lowest precedence among the given options is the comma operator (,). The comma operator evaluates both of its operands and returns the value of the second operand. It is typically used to separate multiple expressions within a larger expression. The other operators listed, "!=" (not equal), "&&" (logical AND), and "?: " (ternary conditional), have higher precedence than the comma operator.

Submit
8. What function should be used to free the memory allocated by calloc()?

Explanation

The correct answer is "free();". The function free() is used to deallocate the memory that was allocated using functions like malloc(), calloc(), or realloc(). It takes a pointer to the memory block as its argument and releases the memory, making it available for reuse.

Submit
9. What function should be used to free the memory allocated by calloc()?

Explanation

The function that should be used to free the memory allocated by calloc() is free(). The calloc() function is used to allocate memory for an array of elements, and the free() function is used to deallocate that memory once it is no longer needed. By calling free(), the memory previously allocated by calloc() is released and can be reused for other purposes.

Submit
10.  In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments should be appropriately expanded, are we required to make any special provision?  

Explanation

In Turbo C/C++ under DOS, if we want wild card characters in the command-line arguments to be appropriately expanded, we are required to make a special provision. This means that we need to write code or include a function that handles the expansion of wild card characters in the command-line arguments. Without this special provision, the wild card characters will not be expanded automatically.

Submit
11. Does there exist any way to make the command-line arguments available to other functions without passing them as arguments to the function?

Explanation

There are several ways to make command-line arguments available to other functions without passing them as arguments. One common approach is to use global variables, where the command-line arguments are stored in a global variable that can be accessed by any function within the program. Another approach is to use a configuration file, where the command-line arguments are stored and can be read by any function that needs them. Additionally, some programming languages provide built-in mechanisms for accessing command-line arguments without passing them as arguments to functions.

Submit
12. What will be the output of the program? #include   int main() {     const c = -11;     const int d = 34;     printf("%d, %d\n", c, d);     return 0; }  

Explanation

The program will output "-11, 34". The variable "c" is declared as a constant with a value of -11, and the variable "d" is declared as a constant integer with a value of 34. The printf statement will print the values of "c" and "d" as "%d" placeholders, resulting in the output "-11, 34".

Submit
13.  Are the following two statement same?                      1.         a <= 20 ? (b = 30): (c = 30);                      2.         (a <=20) ? b : (c = 30);  

Explanation

The two statements are not the same. In the first statement, if a is less than or equal to 20, then b is assigned the value 30; otherwise, c is assigned the value 30. In the second statement, if a is less than or equal to 20, then the value of b is returned; otherwise, c is assigned the value 30. The difference lies in the assignment of values.

Submit
14. Will the printf() statement print the same values for any values of a?#includeint main(){    float a;    scanf("%f", &a);    printf("%f\n", a+a+a);    printf("%f\n", 3*a);    return 0;} 

Explanation

The printf() statement will print the same values for any values of a because both printf() statements are calculating and printing the same expression, which is a+a+a and 3*a respectively. Therefore, the output will be the same regardless of the value of a.

Submit
15.  Will the program outputs "IndiaBIX.com"?  #includeint main(){    char str1[] = "IndiaBIX.com";    char str2[20];    strncpy(str2, str1, 8);    printf("%s", str2);    return 0;} 

Explanation

The program will not output "IndiaBIX.com" because the strncpy function is used to copy a specified number of characters from one string to another. In this case, it will copy the first 8 characters from str1 to str2. Therefore, the program will output only "IndiaBIX" as str2 will only contain those 8 characters.

Submit
16.  Bitwise | can be used to multiply a number by powers of 2. 

Explanation

The statement is incorrect. The bitwise OR operator (|) is not used to multiply a number by powers of 2. Instead, it is used to perform a bitwise OR operation on the individual bits of two numbers. To multiply a number by powers of 2, the bitwise left shift operator (

Submit
17. The name of the variable used in one function cannot be used in another function.

Explanation

The statement is false because variables used in one function can be accessed and used in another function as long as they are in the same scope or if they are passed as arguments to the other function. Variables can have global scope, which means they can be accessed from anywhere within the program, or local scope, which means they can only be accessed within the specific function they are defined in.

Submit
18. Which of the following is a ternary operator?

Explanation

The ternary operator, represented by "?:" in programming languages, is a conditional operator that takes three operands. It evaluates a condition and returns one of two values based on the result of the condition. The first operand is the condition to be evaluated, the second operand is the value to be returned if the condition is true, and the third operand is the value to be returned if the condition is false. In this case, "?:" is the only option that represents a ternary operator.

Submit
19. Which of the following statements are correct about the program? #include int main() {     int x = 30, y = 40;     if(x == y)         printf("x is equal to y\n");       else if(x > y)         printf("x is greater than y\n");       else if(x < y)         printf("x is less than y\n")     return 0; }  

Explanation

The correct answer is "Error: Statement missing". This is because there is a missing semicolon at the end of the line where the printf statement is located. This results in a syntax error, as the compiler expects a statement to be present before the return statement.

Submit
20. What is the output of this C code?      #include       int main()      {          int a = 10;          double b = 5.6;          int c;          c = a + b;          printf("%d", c);      } 

Explanation

The code declares an integer variable "a" with a value of 10 and a double variable "b" with a value of 5.6. It then declares an integer variable "c" without initializing it. The expression "a + b" adds the value of "a" and the truncated value of "b" (5), resulting in 15. The printf statement then outputs the value of "c" as an integer, which is 15.

Submit
21. Point out the error in the program? struct emp {     int ecode;     struct emp e; };  

Explanation

The error in the program is in the structure declaration. The structure "emp" contains a member "e" of the same structure type "emp". This creates a recursive definition of the structure, which is not allowed in C. To fix the error, the member "e" should be declared as a pointer to the structure "emp" instead of directly including the structure itself.

Submit
22. What does the following declaration signify? int *f();  

Explanation

The declaration "int *f();" signifies that f is a function that returns a pointer to an int. The syntax "int *" indicates that the return type of the function is a pointer, and "f()" indicates that f is a function. Therefore, the correct answer is "f is a function returning pointer to an int."

Submit
23. What is the output of this C code?           #include            int main()           {                FILE *fp = stdout;                    int n;                 fprintf(fp, "%d\n ", 45);                 fprintf(stderr, "%d ", 65);                 return 0;             } 

Explanation

The code includes the standard input/output library and defines a main function. It declares a FILE pointer variable named 'fp' and initializes it to the standard output stream 'stdout'. It also declares an integer variable 'n'. The code then uses the fprintf function to print the value 45 followed by a line break to the 'fp' stream, which is the standard output. It also uses fprintf to print the value 65 to the standard error stream 'stderr'. Finally, the code returns 0. Therefore, the output of the code will be "45 65", with the numbers separated by a space.

Submit
24. What is the output of this C code?                #include                 void main()                {                    #define max 45                    max = 32;                    printf("%d", max);                } 

Explanation

The code tries to redefine the macro "max" with a new value of 32 after it has already been defined as 45. This is not allowed in C, as macros are meant to be constants and cannot be changed once defined. Therefore, the code will result in a compile time error.

Submit
25. What will be the output of the program if the array begins 1200 in memory?#include int main(){    int arr[]={2, 3, 4, 1, 6};    printf("%u, %u, %u\n", arr, &arr[0], &arr);    return 0;} 

Explanation

The program is printing the memory addresses of the array and its first element. Since the array begins at memory address 1200, the first output is 1200. The second output is also 1200 because the address of the first element of the array is the same as the address of the array itself. The third output is also 1200 because the address of the array is the same as the address of the first element of the array.

Submit
26. What do the following declaration signify? void *cmp();  

Explanation

The declaration "void *cmp();" signifies that cmp is a function that returns a void pointer. The use of "*" before cmp indicates that cmp is a pointer, and the "void" before the "*" indicates that the pointer points to a void type. Since the function is declared to return a void pointer, it means that the function does not have a specific return type and can return a pointer to any type.

Submit
27. Which of the following is the correct order of evaluation for the below expression? z = x + y * z / 4 % 2 - 1  

Explanation

The correct order of evaluation for the given expression is as follows: first, the multiplication operation is performed (y * z), then the division operation is performed (y * z / 4), next the modulus operation is performed (y * z / 4 % 2), then the addition operation is performed (x + y * z / 4 % 2), and finally the subtraction operation is performed (x + y * z / 4 % 2 - 1).

Submit
28.  Associativity of an operator are:

Explanation

The explanation for the given correct answer is that the associativity of an operator can be either right to left or left to right, depending on the operator. Some operators associate from right to left, meaning that the right operand is evaluated first, while others associate from left to right, meaning that the left operand is evaluated first. Therefore, the correct answer is both (a) and (b), as some operators have right to left associativity and others have left to right associativity.

Submit
29. The maximum combined length of the command-line arguments including the spaces between adjacent arguments is 

Explanation

The maximum combined length of command-line arguments can vary from one operating system to another. Different operating systems may have different limits on the maximum length of command-line arguments. Therefore, it is not possible to determine a fixed maximum length without considering the specific operating system being used.

Submit
30. Which of the following fopen statements is illegal?  

Explanation

All of the given fopen statements are legal. The fopen function is used to open a file in different modes such as "r" for reading, "w" for writing, etc. In this case, the first statement opens a file named "abc.txt" in read mode, the second statement opens a file located at "/home/user1/abc.txt" in write mode, and the third statement opens a file named "abc" in write mode. Therefore, none of the fopen statements are illegal.

Submit
31. What is the output of this C code?                #include                 int main()                {                    printf("%d\n", srand(9000));                    return 0;                } 

Explanation

The code includes the header file "stdio.h" which contains the declaration of the printf() function. However, it does not include the header file "stdlib.h" which contains the declaration of the srand() function. This leads to a compile-time error because the compiler does not recognize the srand() function.

Submit
32. What will be the output of the program? #include int main() {     char huge *near *far *ptr1;     char near *far *huge *ptr2;     char far *huge *near *ptr3;     printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3));     return 0; }  

Explanation

The correct answer is 4, 4, 4. This is because the sizeof operator is used to determine the size in bytes of a data type or variable. In this program, **ptr1 refers to the value pointed to by the pointer ptr1, which is a char type. Therefore, sizeof(**ptr1) will return 4, as a char data type typically occupies 1 byte of memory. Similarly, sizeof(ptr2) and sizeof(*ptr3) will also return 4, as they are both pointers and typically occupy 4 bytes of memory on most systems.

Submit
33.  What will be the output of the program ?#include int main(){    char *str;    str = "%d\n";    str++;    str++;    printf(str-2, 300);    return 0;} 

Explanation

The program initializes a character pointer 'str' and assigns it the value "%d". The pointer is then incremented twice. The printf function is called with the argument 'str-2', which points to the original value of 'str'. The format specifier "%d" is used to format the argument 300, so the output of the program will be 300.

Submit
34. What is the output of this C code?                #include                 int main()                {                    char *p = NULL;                    char *q = 0;                    if (p)                        printf(" p ");                    else                        printf("nullp");                    if (q)                        printf("q\n");                    else                        printf(" nullq\n");                } 

Explanation

The output of this C code is "nullp nullq". This is because the variables p and q are both assigned the value NULL, which represents a null pointer. In the if statements, the condition (p) and (q) both evaluate to false since the values of p and q are null. Therefore, the else statements are executed and the strings "nullp" and "nullq" are printed respectively.

Submit
35.  Is there any difference int the following declarations? int fun(int arr[]); int fun(int arr[2]);  

Explanation

There is no difference in the two declarations. Both declarations are specifying a function named "fun" that takes an integer array as a parameter. The size of the array is not specified in either declaration.

Submit
36. What is the output of this C code?       #include       int main()       {           int x = 1, y = 0, z = 3;           x > y ? printf("%d", z) : return z;       }  

Explanation

The code will result in a compile time error. This is because the ternary operator (?:) requires both the true and false expressions to have the same data type. In this case, the true expression is printf("%d", z), which is of type int, while the false expression is return z, which is a statement and not an expression. Therefore, the code will fail to compile.

Submit
37.  What is the output of this C code?                #include                 int main()                {                    short int i;                    scanf("%hd", &i);                    printf("%hd", i);                    return 0;                } 

Explanation

The code snippet uses the scanf function to read input from the user and store it in the variable "i". The format specifier "%hd" is used to indicate that the input should be treated as a short integer. However, the code does not provide the address of the variable "i" to the scanf function, which results in undefined behavior. In this case, the behavior will depend on the compiler and system being used. Therefore, the output will be whatever the user types, but the code may produce unexpected results or errors.

Submit
38. Point out the error in the program? struct emp {     int ecode;     struct emp *e; };  

Explanation

The given program does not have any error. The structure "emp" is correctly declared with an integer variable "ecode" and a pointer variable "e" of type "struct emp".

Submit
39. Property of external variable to be accessed by any source file is called by C90 standard as  

Explanation

The C90 standard refers to the property of an external variable being accessible by any source file as "external linkage". This means that the variable can be accessed and used by other source files in the program. Other options such as "external scope", "global scope", and "global linkage" do not accurately describe this specific property.

Submit
40. What is the output of the code given below?                 #include                 int main()                 {                     char a[1][5] = {"hello"};                     printf("%s", a[0]);                     return 0;                 }  

Explanation

The code given above has undefined behavior because the character array `a` is declared with a size of 1x5, but the string "hello" requires 6 characters (including the null terminator). This means that the string "hello" will overflow the bounds of the array, resulting in undefined behavior.

Submit
41. Which of the following is the correct usage of conditional operators used in C?

Explanation

The correct usage of conditional operators in C is demonstrated in the given answer. The expression "max = a>b ? a>c?a:c:b>c?b:c" assigns the maximum value among three variables a, b, and c to the variable max. The first part of the expression "a>b ? a>c?a:c" checks if a is greater than b, and if true, it further checks if a is greater than c. If both conditions are true, a is assigned to max. Otherwise, c is assigned to max. If the first condition "a>b" is false, the second part of the expression "b>c?b:c" checks if b is greater than c. If true, b is assigned to max. Otherwise, c is assigned to max.

Submit
42.  What is the output of this C code?                #include                 int main()                {                    int i = 10;                    void *p = &i;                    printf("%d\n", (int)*p);                    return 0;                } 

Explanation

The given C code will result in a compile time error. This is because the line "void *p = &i;" is trying to assign the address of an integer variable to a void pointer without any typecasting. Void pointers can hold the address of any data type, but they need to be explicitly typecasted to the correct data type before dereferencing. Since the code is trying to dereference the void pointer without typecasting, it will result in a compile time error.

Submit
43.  Which of the following cannot be checked in a switch-case statement? 

Explanation

A switch-case statement is used to check the value of a variable against multiple cases. It allows for branching based on the value of the variable. In this case, the correct answer is "Float" because switch-case statements can only be used with integer values, character values, and enumerated types. Float values are not allowed as switch-case expressions because they are not discrete values that can be easily compared.

Submit
44. What is the output of this C code?       #include       void main()       {           int n;           scanf("%d", n);           printf("%d", n);       }  

Explanation

The code is trying to read an integer from the user using the scanf() function and store it in the variable 'n'. However, there is a mistake in the code. The second argument of scanf() function should be the address of the variable where the input should be stored. In this case, it should be '&n' instead of 'n'. Since the correct address is not passed to scanf(), it will result in undefined behavior and can cause a segmentation fault or any other unpredictable output. In this case, the output will be nothing because the value of 'n' is not initialized and it will print garbage value.

Submit
45. What will be the output of the program? #include   int main() {     printf(5+"IndiaBIX\n");     return 0; }  

Explanation

The program will output "BIX". The expression "5+"IndiaBIX"" adds the number 5 to the address of the string "IndiaBIX". This results in the program printing the characters starting from the 5th position of the string, which is "BIX".

Submit
46. Point out the correct statements are correct about the program below? #include int main() {     char ch;     while(x=0;x<=255;x++)         printf("ASCII value of %d character %c\n", x, x);     return 0; }

Explanation

The given code has a syntax error because the while statement is missing the condition. The correct syntax for the while statement is while(condition). Since the condition is missing, the code will not compile and will result in an error.

Submit
47. Which of the following data type will throw an error on modulus operation(%)?

Explanation

The modulus operation (%) is used to find the remainder when one number is divided by another. It can only be performed on integer types, such as char, short, and int. However, when trying to perform the modulus operation on a float data type, it will throw an error because float is a floating-point type and not an integer type.

Submit
48. Point out the error in the following program. #include   int main() {     char str[] = "IndiaBIX";     printf("%.#s %2s", str, str);     return 0; }  

Explanation

The given program does not contain any errors.

Submit
49.  What is the output of this C code?           #include            int main()          {             char n[] = "hellonworld!";                char s[13];               sscanf(n, "%s", s);                printf("%s\n", s);                                return 0;            } 

Explanation

The code declares a character array "n" with the value "hellonworld!" and another character array "s" with a size of 13. The sscanf function is used to read a string from "n" and store it in "s". The format specifier "%s" is used to read a string until a whitespace character is encountered. The printf function then prints the value of "s", which is "hello" as the whitespace character after "hello" in "n" terminates the string. Therefore, the output of the code is "hello".

Submit
50. Can variable I be accessed by functions in another source file?       #include       int i;       int main()       {           printf("%d\n", i);       }  

Explanation

The variable i can be accessed by functions in another source file because it is declared outside of any function, making it a global variable. Global variables can be accessed by any function within the same program.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

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

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 30, 2017
    Quiz Created by
    Nishad
Cancel
  • All
    All (50)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
 Which of the following is not an arithmetic operation?  
The precedence of arithmetic operators is (from highest to lowest)
What will be the output of the program ?...
The library function used to reverse a string is ____ 
 If a function contains two return statements successively, the...
We can modify the pointers "source" as well as...
Which of the following operators has the lowest precedence?
What function should be used to free the memory allocated by calloc()?
What function should be used to free the memory allocated by calloc()?
 In Turbo C/C++ under DOS if we want that any wild card...
Does there exist any way to make the command-line arguments available...
What will be the output of the program?...
 Are the following two statement same?...
Will the printf() statement print the same values for any values of...
 Will the program outputs...
 Bitwise | can be used to multiply a number by powers of 2. 
The name of the variable used in one function cannot be used in...
Which of the following is a ternary operator?
Which of the following statements are correct about the program?...
What is the output of this C code? ...
Point out the error in the program?...
What does the following declaration signify? int *f();  
What is the output of this C code?      ...
What is the output of this C...
What will be the output of the program if the array begins 1200 in...
What do the following declaration signify? void *cmp();  
Which of the following is the correct order of evaluation for the...
 Associativity of an operator are:
The maximum combined length of the command-line arguments including...
Which of the following fopen statements is illegal?  
What is the output of this C...
What will be the output of the program?...
 What will be the output of the program ?#include int...
What is the output of this C...
 Is there any difference int the following declarations?...
What is the output of this C code?...
 What is the output of this C...
Point out the error in the program?...
Property of external variable to be accessed by any source file is...
What is the output of the code given below?...
Which of the following is the correct usage of conditional operators...
 What is the output of this C...
 Which of the following cannot be checked in a switch-case...
What is the output of this C code?...
What will be the output of the program?...
Point out the correct statements are correct about the program below?...
Which of the following data type will throw an error on modulus...
Point out the error in the following program....
 What is the output of this C...
Can variable I be accessed by functions in another source file?...
Alert!

Advertisement