Blind Coding C Programming Quiz!

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 Nishad
N
Nishad
Community Contributor
Quizzes Created: 1 | Total Attempts: 1,189
Questions: 50 | Attempts: 1,189

SettingsSettingsSettings
Blind Coding C Programming Quiz! - Quiz

.


Questions and Answers
  • 1. 

    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; }

    • A.

      The code generates an infinite loop

    • B.

      The code prints all ASCII values and its characters

    • C.

      Error: x undeclared identifier

    • D.

      Error: while statement missing

    Correct Answer
    D. Error: while statement missing
    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.

    Rate this question:

  • 2. 

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

    • A.

      A. a>b ? c=30 : c=40;

    • B.

      A>b ? c=30;

    • C.

      Max = a>b ? a>c?a:c:b>c?b:c

    • D.

      Return (a>b)?(a:b)

    Correct Answer
    C. Max = a>b ? a>c?a:c:b>c?b: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.

    Rate this question:

  • 3. 

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

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    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.

    Rate this question:

  • 4. 

    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; }  

    • A.

      5

    • B.

      4

    • C.

      6

    • D.

      7

    Correct Answer
    B. 4
    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.

    Rate this question:

  • 5. 

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

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    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.

    Rate this question:

  • 6. 

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

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    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.

    Rate this question:

  • 7. 

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

    • A.

      Dealloc();

    • B.

      Malloc(variable_name, 0)

    • C.

      Free();

    • D.

      Memalloc(variable_name, 0)

    Correct Answer
    C. Free();
    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.

    Rate this question:

  • 8. 

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

    • A.

      Cmp is a pointer to an void type

    • B.

      Cmp is a void type pointer variable.

    • C.

      Cmp is a function that return a void pointer.

    • D.

      Cmp function returns nothing.

    Correct Answer
    C. Cmp is a function that return a void pointer.
    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.

    Rate this question:

  • 9. 

    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; }  

    • A.

      4, 4, 4

    • B.

      2, 2, 2

    • C.

      2, 8, 4

    • D.

      2, 4, 8

    Correct Answer
    A. 4, 4, 4
    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.

    Rate this question:

  • 10. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    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.

    Rate this question:

  • 11. 

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

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    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.

    Rate this question:

  • 12. 

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

    • A.

      Character

    • B.

      Integer

    • C.

      Float

    • D.

      Enum

    Correct Answer
    C. Float
    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.

    Rate this question:

  • 13. 

    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; }  

    • A.

      Error: Statement missing

    • B.

      Error: Expression syntax

    • C.

      Error: Lvalue required

    • D.

      Error: Rvalue required

    Correct Answer
    A. Error: Statement missing
    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.

    Rate this question:

  • 14. 

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

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    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.

    Rate this question:

  • 15. 

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

    • A.

      No output

    • B.

      30

    • C.

      3

    • D.

      300

    Correct Answer
    D. 300
    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.

    Rate this question:

  • 16. 

    The library function used to reverse a string is ____ 

    • A.

      Strstr()

    • B.

      Strrev()

    • C.

      Revstr()

    • D.

      Strreverse()

    Correct Answer
    B. Strrev()
    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.

    Rate this question:

  • 17. 

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

    • A.

      Error: in structure declaration

    • B.

      Linker Error

    • C.

      No Error

    • D.

      None of above

    Correct Answer
    C. No Error
    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".

    Rate this question:

  • 18. 

     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?  

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    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.

    Rate this question:

  • 19. 

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

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    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 (

    Rate this question:

  • 20. 

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

    • A.

      F is a pointer variable of function type.

    • B.

      F is a function returning pointer to an int.

    • C.

      F is a function pointer.

    • D.

      F is a simple declaration of pointer variable.

    Correct Answer
    B. F is a function returning pointer to an int.
    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."

    Rate this question:

  • 21. 

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

    • A.

      * / % + - =

    • B.

      = * / % + -

    • C.

      / * % - + =

    • D.

      * % / - + =

    Correct Answer
    A. * / % + - =
    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).

    Rate this question:

  • 22. 

    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;} 

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    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.

    Rate this question:

  • 23. 

    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;} 

    • A.

      1200, 1202, 1204

    • B.

      1200, 1200, 1200

    • C.

      1200, 1204, 1208

    • D.

      1200, 1202, 1200

    Correct Answer
    B. 1200, 1200, 1200
    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.

    Rate this question:

  • 24. 

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

    • A.

      Error

    • B.

      IndiaBIX

    • C.

      BIX

    • D.

      None of above

    Correct Answer
    C. BIX
    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".

    Rate this question:

  • 25. 

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

    • A.

      Error: in structure declaration

    • B.

      Linker Error

    • C.

      No Error

    • D.

      None of above

    Correct Answer
    A. Error: in structure declaration
    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.

    Rate this question:

  • 26. 

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

    • A.

      128 characters

    • B.

      256 characters

    • C.

      67 characters

    • D.

      It may vary from one operating system to another

    Correct Answer
    D. It may vary from one operating system to another
    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.

    Rate this question:

  • 27. 

    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; }  

    • A.

      Error

    • B.

      -11, 34

    • C.

      11, 34

    • D.

      None of these

    Correct Answer
    B. -11, 34
    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".

    Rate this question:

  • 28. 

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

    • A.

      Error: in Array declaration

    • B.

      Error: printf statement

    • C.

      Error: unspecified character in printf

    • D.

      No error

    Correct Answer
    D. No error
    Explanation
    The given program does not contain any errors.

    Rate this question:

  • 29. 

    Which of the following fopen statements is illegal?  

    • A.

      fp = fopen(“abc.txt”, “r”);

    • B.

      Fp = fopen(“/home/user1/abc.txt”, “w”);

    • C.

      Fp = fopen(“abc”, “w”);

    • D.

      None of the mentioned

    Correct Answer
    D. None of the mentioned
    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.

    Rate this question:

  • 30. 

    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;             } 

    • A.

      45 65

    • B.

      65 45

    • C.

      65

    • D.

      Compilation error

    Correct Answer
    A. 45 65
    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.

    Rate this question:

  • 31. 

     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;            } 

    • A.

      Hellonworld!

    • B.

      Hello world!

    • C.

      hello

    • D.

      Hello world!

    Correct Answer
    C. hello
    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".

    Rate this question:

  • 32. 

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

    • A.

      Compilation error

    • B.

      Undefined behavior

    • C.

      Whatever user types

    • D.

      None of the mentioned

    Correct Answer
    C. Whatever user types
    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.

    Rate this question:

  • 33. 

    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");                } 

    • A.

      Nullp nullq

    • B.

      Depends on the compiler

    • C.

      X nullq where x can be p or nullp depending on the value of NULL

    • D.

      p q

    Correct Answer
    A. Nullp nullq
    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.

    Rate this question:

  • 34. 

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

    • A.

      Compile time error

    • B.

      Segmentation fault/runtime crash

    • C.

      10

    • D.

      Undefined behaviour

    Correct Answer
    A. Compile time error
    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.

    Rate this question:

  • 35. 

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

    • A.

      External linkage

    • B.

      External scope

    • C.

      Global scope

    • D.

      Global linkage

    Correct Answer
    A. External linkage
    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.

    Rate this question:

  • 36. 

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

    • A.

      Compile time error

    • B.

      An integer in the range 0 to 9000

    • C.

      A float in the range 0 to 1

    • D.

      A double in the range 0 to 9000

    Correct Answer
    A. Compile time error
    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.

    Rate this question:

  • 37. 

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

    • A.

      32

    • B.

      45

    • C.

      Compile time error

    • D.

      Varies

    Correct Answer
    C. Compile time error
    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.

    Rate this question:

  • 38. 

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

    • A.

      Compile time error

    • B.

      Hello

    • C.

      Undefined behaviour

    • D.

      Hellon

    Correct Answer
    C. Undefined behaviour
    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.

    Rate this question:

  • 39. 

    The precedence of arithmetic operators is (from highest to lowest)

    • A.

      %, *, /, +, –

    • B.

      %, +, /, *, –

    • C.

      +, -, %, *, /

    • D.

      %, +, -, *, /

    Correct Answer
    A. %, *, /, +, –
    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.

    Rate this question:

  • 40. 

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

    • A.

      char

    • B.

      Short

    • C.

      Int

    • D.

      Float

    Correct Answer
    D. Float
    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.

    Rate this question:

  • 41. 

    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);      } 

    • A.

      15

    • B.

      16

    • C.

      15.6

    • D.

      10

    Correct Answer
    A. 15
    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.

    Rate this question:

  • 42. 

     Which of the following is not an arithmetic operation?  

    • A.

      A *= 10;

    • B.

      A /= 10;

    • C.

      A != 10;

    • D.

      A %= 10;

    Correct Answer
    C. A != 10;
    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.

    Rate this question:

  • 43. 

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

    • A.

      True

    • B.

      False

    • C.

      May be

    • D.

      None of the mentioned

    Correct Answer
    B. False
    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.

    Rate this question:

  • 44. 

    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;       }  

    • A.

      3

    • B.

      1

    • C.

      Compile time error

    • D.

      Run time error

    Correct Answer
    C. Compile time error
    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.

    Rate this question:

  • 45. 

    Which of the following is a ternary operator?

    • A.

      &&

    • B.

      >>=

    • C.

      ?:

    • D.

      ->

    Correct Answer
    C. ?:
    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.

    Rate this question:

  • 46. 

     Associativity of an operator are:

    • A.

      Right to Left

    • B.

      Left to Right

    • C.

      Random fashion

    • D.

      Both (a) and (b)

    Correct Answer
    D. Both (a) and (b)
    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.

    Rate this question:

  • 47. 

    Which of the following operators has the lowest precedence?

    • A.

      !=

    • B.

      &&

    • C.

      ?:

    • D.

      ,

    Correct Answer
    D. ,
    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.

    Rate this question:

  • 48. 

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

    • A.

      0

    • B.

      False

    • C.

      Only if static keyword is used

    • D.

      Depends on the type of the variable

    Correct Answer
    A. 0
    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.

    Rate this question:

  • 49. 

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

    • A.

      Prints the number that was entered

    • B.

      Segmentation fault

    • C.

      Nothing

    • D.

      Varies

    Correct Answer
    C. Nothing
    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.

    Rate this question:

  • 50. 

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

    • A.

      Dealloc();

    • B.

      Malloc(variable_name, 0)

    • C.

      Free();

    • D.

      Memalloc(variable_name, 0)

    Correct Answer
    C. Free();
    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.

    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 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 30, 2017
    Quiz Created by
    Nishad
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.