Troubleshoot Round 1 Set 3

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 Trouble Shoot
T
Trouble Shoot
Community Contributor
Quizzes Created: 1 | Total Attempts: 146
Questions: 20 | Attempts: 146

SettingsSettingsSettings
Technical Quizzes & Trivia

Questions and Answers
  • 1. 

    What is the output of the following code? #include<stdio.h> main() {     int n,i;     n=f(6);     printf("%d",n); } f(int x) {     if(x==2)             return 2;     else     {         printf("+");         f(x-1);     } }  

    • A.

      ++++2

    • B.

      +++++

    • C.

      +++++2

    • D.

      2

    Correct Answer
    A. ++++2
    Explanation
    The code is using recursion to print a series of "+" symbols and then return the value 2. The function f(x) is called multiple times with decreasing values of x until x reaches 2. Each time the function is called, it prints a "+" symbol. Once x reaches 2, the function returns 2. Therefore, the output of the code will be a series of "+" symbols followed by the number 2.

    Rate this question:

  • 2. 

    Which is correct with respect to the size of the data types?

    • A.

      Char > int > float

    • B.

      Int > char > float

    • C.

      Char < int < double

    • D.

      Double > char > int

    Correct Answer
    C. Char < int < double
    Explanation
    The correct order of the size of the data types is char < int < double. This means that char takes up the least amount of memory, followed by int, and then double.

    Rate this question:

  • 3. 

    #include <stdio.h>     int main()     {         reverse(1);     }     void reverse(int i)     {         if (i > 5)             exit(0);         printf("%d\n", i);         return reverse(i++);     }

    • A.

      Compile time error

    • B.

      1 2 3 4

    • C.

      1 2 3 4 5

    • D.

      Stack Overflow

    Correct Answer
    D. Stack Overflow
    Explanation
    The given code will result in a stack overflow error. This is because the function reverse is being recursively called without any base case to stop the recursion. As a result, the function will continue to call itself indefinitely, causing the stack to overflow and resulting in a runtime error.

    Rate this question:

  • 4. 

    What is function srand(unsigned)?

    • A.

      Sets the seed for rand

    • B.

      Doesn’t exist

    • C.

      Is an error

    • D.

      None of the mentioned

    Correct Answer
    A. Sets the seed for rand
    Explanation
    The function srand(unsigned) is used to set the seed for the rand function in C++. The seed is a value that initializes the random number generator, allowing for the generation of different sequences of random numbers. By setting the seed using srand, we can ensure that the sequence of random numbers generated by rand is different each time the program is run.

    Rate this question:

  • 5. 

    #define FALSE -1 #define TRUE 1 #define NULL 0 main() {     if(NULL)          puts("NULL");     else if(FALSE)         puts("TRUE");     else         puts("FALSE"); }

    • A.

      NULL

    • B.

      TRUE

    • C.

      FALSE

    • D.

      1

    Correct Answer
    B. TRUE
    Explanation
    The code defines the values of FALSE, TRUE, and NULL as -1, 1, and 0 respectively. In the if statement, NULL is evaluated as false because it has a value of 0. Therefore, the code moves to the else if statement. Since FALSE is defined as -1, it evaluates to true and the code executes the statement "puts("TRUE")". Therefore, the output of the code will be "TRUE".

    Rate this question:

  • 6. 

    Void main() {     int a,b;     a=3,1;     b=(5,4);     printf("%d",a+b); }

    • A.

      Error

    • B.

      6

    • C.

      8

    • D.

      7

    Correct Answer
    D. 7
    Explanation
    In the given code, there are two variables, 'a' and 'b', which are both integers.

    In the line 'a=3,1;', there seems to be a typographical error. Instead of using a comma operator, it should be a semicolon. Therefore, the value of 'a' will be assigned as 3.

    In the line 'b=(5,4);', there is a comma operator used. The comma operator evaluates both expressions and returns the value of the second expression. So, the value of 'b' will be assigned as 4.

    Finally, the sum of 'a' and 'b' is printed, which is 7.

    Rate this question:

  • 7. 

    Int main() { int a; int b=5; a=0 && --b; printf("%d%d",a,b); }

    • A.

      0 5

    • B.

      Compile Time Error

    • C.

      Syntax Error

    • D.

      0 4

    Correct Answer
    A. 0 5
    Explanation
    In this code, the variable 'a' is assigned the value of the logical AND operation between 0 and the pre-decremented value of 'b'. The logical AND operator returns 0 if any of the operands is 0. Since 'b' is initially 5, it is decremented to 4 but this does not affect the value of 'a' as 0 is already 0. Therefore, 'a' remains 0 and 'b' remains 5. The correct answer is 0 5.

    Rate this question:

  • 8. 

    Void Main() { int a=10; printf("%d", a); }

    • A.

      Run Time Error

    • B.

      Compilation Error

    • C.

      10

    • D.

      None Of The Above

    Correct Answer
    A. Run Time Error
    Explanation
    This code will result in a runtime error because the printf function is being used without including the necessary header file. The printf function is part of the standard input/output library, which is declared in the header file "stdio.h". Without including this header file, the compiler will not recognize the printf function, leading to a runtime error.

    Rate this question:

  • 9. 

    Int main(void) {     while(".") {     printf("Quest"); } return 0; }

    • A.

      Quest(Infinity Times)

    • B.

      Error

    • C.

      Segmentation Fault

    • D.

      None Of The Above

    Correct Answer
    A. Quest(Infinity Times)
    Explanation
    The given code is an infinite loop because the condition of the while loop is a non-null string literal ("."). Since the condition is always true, the loop will continue indefinitely. Inside the loop, the code prints "Quest" repeatedly. Therefore, the output will be "Quest" repeated infinitely.

    Rate this question:

  • 10. 

    Int main() {     char str[10]="Quest";     printf("%d,%d\n",strlen(str),sizeof(str));     return 0; }

    • A.

      5,10

    • B.

      5,8

    • C.

      5,6

    • D.

      Error

    Correct Answer
    A. 5,10
    Explanation
    The code snippet declares a character array `str` with a size of 10 and initializes it with the string "Quest". The `strlen` function is used to determine the length of the string, which is 5 characters. The `sizeof` function is used to determine the size of the character array, which is 10 bytes. Therefore, the correct answer is 5,10.

    Rate this question:

  • 11. 

    #include <stdio.h>     int main()     {         int x = 2, y = 0;         int z = y && (y |= 10);         printf("%d\n", z);         return 0;     }

    • A.

      Undefined behaviour due to order of evaluation

    • B.

      0

    • C.

      1

    • D.

      2

    Correct Answer
    B. 0
    Explanation
    The code snippet is using the logical AND operator (&&) to evaluate the expression "y && (y |= 10)". In this expression, the value of y is first evaluated, which is 0. Then, the second part of the expression is evaluated, which is "y |= 10". This expression is performing a bitwise OR operation between y and 10, and then assigning the result back to y. However, since the value of y is 0, the bitwise OR operation will not change the value of y. Finally, the overall expression evaluates to 0 because the logical AND operator requires both operands to be true, but since the value of y is 0, it is considered false. Therefore, the value of z is 0.

    Rate this question:

  • 12. 

    Main(int arg,char **argv) {    printf("Enter the character");    getchar();    sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; {     return num1+num2; }

    • A.

      No Error

    • B.

      Compile Error

    • C.

      No Output

    • D.

      Run Time Error

    Correct Answer
    B. Compile Error
    Explanation
    The given code will result in a compile error because the function sum() is not declared before it is used in the main() function. In C, functions need to be declared before they are used, either by including a function prototype at the beginning of the file or by defining the function before it is used. Since the sum() function is defined after it is used in the main() function, the compiler will not be able to recognize it and will throw a compile error.

    Rate this question:

  • 13. 

    _______ occurs when a result is too large in magnitude to represent errors as a floating-point value of the required type.

    • A.

      Underflow

    • B.

      Overflow

    • C.

      Signi?cance loss

    • D.

      Domain

    Correct Answer
    A. Underflow
    Explanation
    Underflow occurs when a result is too small in magnitude to be represented accurately as a floating-point value of the required type. In other words, it happens when a number is so close to zero that it cannot be precisely represented using the available number of bits. This can lead to loss of precision and inaccuracies in calculations.

    Rate this question:

  • 14. 

    Which one do you like?#include <stdio.h>     int main()     {         int i = 0;         int j = i++ + i;         printf("%d\n", j);     }

    • A.

      Compile time error

    • B.

      0

    • C.

      1

    • D.

      2

    Correct Answer
    C. 1
    Explanation
    The given code snippet initializes two variables, i and j, with i being assigned a value of 0. The expression i++ + i is then evaluated and assigned to j. The post-increment operator (i++) increments the value of i after it has been used in the expression, so j is assigned the value of 0 + 1, which is 1. Finally, the value of j is printed, resulting in the output of 1.

    Rate this question:

  • 15. 

    Void test(struct number n) {     n.x=100; } struct number{ int x; }; int main() {     struct number num;     test(num);     printf("%d\n",num.x);         return 0; }

    • A.

      10

    • B.

      100

    • C.

      No output

    • D.

      Error

    Correct Answer
    D. Error
    Explanation
    The code is attempting to pass a struct as an argument to a function, but the struct is not defined before the function prototype. This results in a compilation error because the compiler does not know the definition of the struct when it encounters the function call. Therefore, the correct answer is "Error".

    Rate this question:

  • 16. 

    Int main() {     int x=5;     if(x>=10)       printf("Quest");     printf("CSE");     else  printf("2K19"); }

    • A.

      No output

    • B.

      Compilation Error

    • C.

      QuestCSE

    • D.

      2K19

    Correct Answer
    B. Compilation Error
    Explanation
    The given code will result in a compilation error. This is because the ">" symbol is not properly encoded as ">" in the code. Therefore, the code will not be able to compile and will result in a compilation error.

    Rate this question:

  • 17. 

    In the absence of a exit condition in a recursive function, the following error is given __________

    • A.

      Compile Time Error

    • B.

      Run Time Error

    • C.

      Logical Error

    • D.

      No error

    Correct Answer
    B. Run Time Error
    Explanation
    In the absence of an exit condition in a recursive function, the function will keep calling itself indefinitely, leading to a stack overflow. This will result in a runtime error as the program will run out of memory to allocate for the function calls.

    Rate this question:

  • 18. 

    Examination of the program step by step is called ______________

    • A.

      Tracing

    • B.

      Stepping

    • C.

      Controlling

    • D.

      Testing

    Correct Answer
    B. Stepping
    Explanation
    Stepping refers to the process of examining a program step by step, allowing for a detailed analysis of its execution. It involves pausing the program at each step to observe the values of variables, the flow of control, and the effects of each instruction. This technique is commonly used in debugging to identify and fix errors in the code. By carefully stepping through the program, programmers can gain a better understanding of its behavior and pinpoint any issues that may be causing unexpected results.

    Rate this question:

  • 19. 

    #include<stdio.h> int main() {     int fun={     printf("C for Loop");     };     int x=5;     for(x=0;x<=fun;x++)     {        printf("%x",x);     }      }

    • A.

      0 1 2 3 4 5 6 7 8 9

    • B.

      C for Loop0 1 2 3 4 5 6 7 8 9 a

    • C.

      Compile Time Error

    • D.

      0 1 2 3 4 5 6 7 8 9 a

    Correct Answer
    C. Compile Time Error
    Explanation
    The code provided has a syntax error. The variable "fun" is declared as an integer but is assigned a block of code instead of a value. This is not valid in C programming. Therefore, a compile-time error will occur.

    Rate this question:

  • 20. 

    #include<stdio.h> #define x 5+2 int main( ) {      int i;      i=x*x*x;      printf("%d",i);      return 0; }

    • A.

      27

    • B.

      343

    • C.

      233

    • D.

      Compiler Error

    Correct Answer
    A. 27
    Explanation
    The program defines a macro `x` as `5+2`. In the `main` function, the variable `i` is assigned the value of `x*x*x`, which is equivalent to `5+2*5+2*5+2`, which simplifies to `5+10+10+2`, resulting in `27`. The program then prints the value of `i`, which is `27`.

    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
  • Mar 11, 2019
    Quiz Created by
    Trouble Shoot
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.