Test On C Programming Skills! Trivia 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 Pranay573
P
Pranay573
Community Contributor
Quizzes Created: 4 | Total Attempts: 15,908
Questions: 10 | Attempts: 1,728

SettingsSettingsSettings
Test On C Programming Skills! Trivia Quiz - Quiz

.


Questions and Answers
  • 1. 

    #include<stdio.h> void main() { struct emp { char name[20]; int age; float sal; }; struct emp e={"Tiger"}; printf("\n %d %f",e.age,e.sal); }  

    • A.

      0 0.000000

    • B.

      Garbage values

    • C.

      Error

    • D.

      None of the above

    Correct Answer
    A. 0 0.000000
    Explanation
    When an automatic structure is partially initialized, the remaining elements of the structure are initialized to 0.

    Rate this question:

  • 2. 

    Which of the following set of statements is correct?

    • A.

      Typedef long a; extern int a c;

    • B.

      Typedef long a; extern a int c:

    • C.

      Typedef long a; extern a c;

    Correct Answer
    C. Typedef long a; extern a c;
    Explanation
    The correct answer is "typedef long a; extern a c;". This is because the first statement declares a typedef for a long integer called "a", and the second statement declares an extern variable of type "a" called "c". This is the correct syntax for declaring a typedef and an extern variable.

    Rate this question:

  • 3. 

    By default a real number is treated as

    • A.

      Float

    • B.

      Double

    • C.

      Long double

    • D.

      Depends on the memory model you are using

    Correct Answer
    B. Double
    Explanation
    By default, a real number is treated as a double. The double data type is a 64-bit floating-point number that can represent a wider range of values with greater precision compared to the float data type. Therefore, when a real number is not explicitly declared with a specific data type, it is assumed to be a double.

    Rate this question:

  • 4. 

    How many times the following program will print "Jamboree"? #include<stdio.h> void main() { printf("\n Jamboree"); main(); }

    • A.

      Infinite number of times

    • B.

      32767 times

    • C.

      65535 times

    • D.

      Till the stact doesn't overflow

    Correct Answer
    D. Till the stact doesn't overflow
    Explanation
    The program will print "Jamboree" until the stack doesn't overflow. This is because the main function calls itself recursively without any condition to stop the recursion. As a result, the program will keep printing "Jamboree" indefinitely until the stack memory is exhausted and overflows.

    Rate this question:

  • 5. 

    Is it true that too many recursive calls may result in stack overflow?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Too many recursive calls can result in a stack overflow because each recursive call adds a new stack frame to the call stack. If the recursion continues for a large number of times without a base case or proper termination condition, the call stack can become filled with a large number of stack frames, eventually exceeding the stack's capacity. This leads to a stack overflow error, causing the program to terminate abruptly.

    Rate this question:

  • 6. 

    Predict the output of the following program #include<stdio.h> #define SQR(x) (x*x) void main() { int a,b=3; a=SQR(b+2); printf("\n %d",a); }

    • A.

      25

    • B.

      11

    • C.

      Error

    • D.

      Garbage value

    Correct Answer
    B. 11
    Explanation
    Because,on preprocessing the expression becomes a=(3+2*3+2)

    Rate this question:

  • 7. 

    Predict the output of the following program #include<stdio.h> void main() { static char *s[ ]={"black","white","pink","violet"}; char **ptr[ ]={s+3,s+2,s+1,s}, ***p; p=ptr; ++p; printf("%s", **p+1); }  

    • A.

      Ink

    • B.

      Ack

    • C.

      Ite

    • D.

      Let

    Correct Answer
    A. Ink
    Explanation
    The program declares an array of strings named "s" and an array of pointers to pointers to char named "ptr". The array "s" contains the strings "black", "white", "pink", and "violet". The array "ptr" is assigned the addresses of the elements in "s" in reverse order. The pointer "p" is assigned the address of the first element in "ptr". The statement "++p" increments the pointer "p" to point to the next element in "ptr", which is the address of the string "pink". The statement "printf("%s", **p+1)" prints the string starting from the second character of "pink", which is "ink".

    Rate this question:

  • 8. 

    Predict the output of the following program #include<stdio.h> #include<string.h> void main() { char str[ ]="sales\0\man\0"; printf("%s",str); }  

    • A.

      Man

    • B.

      Sales

    • C.

      Sales man

    • D.

      Sales\0man

    Correct Answer
    B. Sales
    Explanation
    The program declares a character array "str" and assigns it the value "sales\man\0". The printf statement then prints the value of "str". Since there are no formatting specifiers in the printf statement, it will simply print the string as it is. Therefore, the output of the program will be "sales".

    Rate this question:

  • 9. 

    The library function used to reverse the string is

    • A.

      Strstr( )

    • B.

      Strrev( )

    • C.

      Revstr( )

    • D.

      None of the above

    Correct Answer
    B. Strrev( )
    Explanation
    The correct answer is "strrev( )". This is because the "strrev( )" function is a library function that is commonly used to reverse a string. It takes a string as input and returns the reversed string as output.

    Rate this question:

  • 10. 

    Malloc( ) allocates memory from the heap and not from the stack

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The malloc() function in C is used to allocate memory dynamically from the heap. The heap is a region of memory that is used for dynamic memory allocation. On the other hand, the stack is a region of memory used for storing local variables and function calls. When memory is allocated using malloc(), it is not allocated on the stack but rather on the heap. Therefore, the statement that malloc() allocates memory from the heap and not from the stack is true.

    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
  • Sep 17, 2011
    Quiz Created by
    Pranay573
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.