Trouble Shoot Round-1 Set-1

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

SettingsSettingsSettings
Programmer Quizzes & Trivia

.


Questions and Answers
  • 1. 

    Int main() {     int c=2;     switch(c)     {         case 0: printf("CSE");         case 1: printf("Quest");         case 2: printf("Trouble");         case 3: printf("Shoot");         default: printf("2k19");     }     return 0; }

    • A.

      CSEQuest2k19

    • B.

      TroubleShoot2k19

    • C.

      2k19

    • D.

      Quest2k19

    Correct Answer
    B. TroubleShoot2k19
    Explanation
    The correct answer is "TroubleShoot2k19" because the switch statement is evaluating the value of the variable c. Since c is equal to 2, it matches the case 2 and prints "Trouble". However, there are no break statements after each case, so the execution continues to the next cases. As a result, it also prints "Shoot" and "2k19". Therefore, the final output is "TroubleShoot2k19".

    Rate this question:

  • 2. 

    How many times "Trouble Shoot" will print? int main()  {   int x;   for(x=-1; x<=10; x++)   {     if(x < 5)       continue;     else       break;     printf("Trouble Shoot");   }    return 0; }

    • A.

      Infinite Time

    • B.

      11 Times

    • C.

      0 Time

    • D.

      Error

    Correct Answer
    C. 0 Time
    Explanation
    The loop will run 6 times because x starts at -1 and increments by 1 each time until it reaches 5. However, when x is 5, the condition in the if statement is not satisfied, so the loop is exited and "Trouble Shoot" is not printed at all. Therefore, the correct answer is 0 times.

    Rate this question:

  • 3. 

    3. int main() {   char arr[5]="Quest";   printf("%s", arr);   return 0;  }

    • A.

      Quest

    • B.

      Q

    • C.

      Garbage Value

    • D.

      Compilation Error

    Correct Answer
    A. Quest
    Explanation
    The code declares an array of characters called "arr" with a size of 5. The string "Quest" is assigned to the array. The printf function is then used to print the string stored in "arr". Therefore, the output of the code will be "Quest".

    Rate this question:

  • 4. 

    Int main() {   int a = 100, b = 74;   if (a++ > 100 && b++ > 200)     printf("High values with a = %d b = %dn", a, b);   if (a++ < 100 || b++ < 200)     printf("Low values with a = %d b = %dn", a, b);  }

    • A.

      Low values with a = 100 b = 74

    • B.

      Low values with a = 100 b = 73

    • C.

      Low values with a = 102 b = 75

    • D.

      Low values with a = 102 b = 74

    Correct Answer
    C. Low values with a = 102 b = 75
    Explanation
    The correct answer is "Low values with a = 102 b = 75" because the if statement `(a++ < 100 || b++ < 200)` evaluates to true. In this statement, `a++` is post-incremented, so its value is first compared with 100 (which is false), but then it is incremented to 101. On the other hand, `b++` is also post-incremented, so its value is first compared with 200 (which is false), but then it is incremented to 75. Since the condition of the if statement is true, the printf statement inside it is executed, printing the values of a and b as 102 and 75 respectively.

    Rate this question:

  • 5. 

    Int main() {   int x = 0, y = 0;   if(x > 0)     if(y > 0)       printf("True");    else     printf("False");  }

    • A.

      No Output

    • B.

      True

    • C.

      False

    • D.

      Error Because of dangling else problem

    Correct Answer
    A. No Output
    Explanation
    The correct answer is "No Output" because the condition `x > 0` is not satisfied, so the inner `if` statement is not executed. Therefore, there is no output printed.

    Rate this question:

  • 6. 

    Int main() {  int x,y,z;  x = '1'-'0'; /* line-1 */  y = 'a'-'b'; /* line-2 */  z = x + y;  printf("%d",z);  } 

    • A.

      0

    • B.

      Error because of incorrect line-1 only

    • C.

      Error because of incorrect line-1 and line-2.

    • D.

      Error because of incorrect line-2 only.

    Correct Answer
    A. 0
    Explanation
    The correct answer is 0 because the expression '1'-'0' in line-1 will result in the integer value 1-0=1. Similarly, the expression 'a'-'b' in line-2 will result in the integer value 97-98=-1. Therefore, the value of x is 1 and the value of y is -1. When x and y are added together in line-3, the result is 1+(-1)=0. Finally, the value of z is printed, which is 0.

    Rate this question:

  • 7. 

    Examination of the program step by step is called ______________

    • A.

      Controlling

    • B.

      Stepping

    • C.

      Tracing

    • D.

      Testing

    Correct Answer
    B. Stepping
    Explanation
    Stepping refers to the process of examining a program step by step, allowing the programmer to analyze the execution flow and identify any errors or bugs. It involves executing the program line by line, pausing at each step to observe the variables, data values, and program state. This method helps in understanding the program's behavior and identifying the exact point where an error occurs. By stepping through the code, programmers can effectively debug and troubleshoot their programs.

    Rate this question:

  • 8. 

    #include<stdio.h> #include<stdlib.h> int main() {     unsigned char;     FILE *fp;     fp=fopen("trial", "r");     if(!fp)     {         printf("Unable to open file");         exit(1);     }     fclose(fp);     return 0; }

    • A.

      Error: in unsigned char statement

    • B.

      Error: unknown file pointer

    • C.

      No Error

    • D.

      None of above

    Correct Answer
    C. No Error
    Explanation
    The given code does not contain any syntax errors or logical errors. The code opens a file named "trial" in read mode using the fopen() function. If the file does not exist or cannot be opened, the code prints "Unable to open file" and exits the program. Otherwise, the code closes the file using the fclose() function and returns 0. Therefore, there is no error in the code.

    Rate this question:

  • 9. 

    #include<stdio.h> int main() {     char ch;     int i;     scanf("%c", &i);     scanf("%d", &ch);     printf("%c %d", ch, i);     return 0; }

    • A.

      Error: suspicious char to in conversion in scanf()

    • B.

      Error: we may not get input for second scanf() statement

    • C.

      No error

    • D.

      None of above

    Correct Answer
    B. Error: we may not get input for second scanf() statement
    Explanation
    The correct answer is "Error: we may not get input for second scanf() statement". This is because the format specifier used in the first scanf() statement is incorrect. The variable 'i' is an integer, but the format specifier used is '%c' which is for characters. This will cause an error and the input for 'i' will not be read correctly. As a result, the second scanf() statement may not receive any input, leading to an error.

    Rate this question:

  • 10. 

    Int main() {     int x[10]={0,1,2,3,4,5,6,7,8,9};     int *ptr1,*ptr2;     ptr1=&x[0];     ptr2=&x[5];          printf("%p\n",(ptr1+ptr2));          return 0; }

    • A.

      Compilation Error

    • B.

      Garbage Value

    • C.

      Some Random Address

    • D.

      No Error

    Correct Answer
    A. Compilation Error
    Explanation
    The expression `(ptr1+ptr2)` is not valid because it is trying to add two pointers together. Pointer arithmetic can only be performed when adding or subtracting an integer value to a pointer. In this case, `ptr1` and `ptr2` are both pointers to integers, so adding them together is not allowed. Therefore, the code will not compile and a compilation error will occur.

    Rate this question:

  • 11. 

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

    • A.

      5,10

    • B.

      5,8

    • C.

      5,6

    • D.

      5,5

    Correct Answer
    B. 5,8
    Explanation
    The code snippet declares a character pointer variable `str` and assigns it the address of the string "Quest". The `strlen()` function is then used to calculate the length of the string, which is 5. The `sizeof()` function is used to determine the size of the pointer variable `str`, which is 8 bytes on most systems. Therefore, the output of the `printf()` function will be "5,8".

    Rate this question:

  • 12. 

    #include<stdio.h>    #include<stdlib.h>      int main()    {        char *ptr;        free(ptr);        return 0           }

    • A.

      This program will print nothing after execution

    • B.

      Segmentation fault

    • C.

      Aborted (core dumped)

    • D.

      None of the mentioned

    Correct Answer
    C. Aborted (core dumped)
    Explanation
    The program is attempting to free a pointer variable without allocating any memory to it. This results in undefined behavior and can lead to a segmentation fault or an aborted program with a core dump. In this case, the program is likely to be aborted and a core dump is generated.

    Rate this question:

  • 13. 

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

    • A.

      Quest(Infinity Times)

    • B.

      Error

    • C.

      Segmentation Fault

    • D.

      None of the Above

    Correct Answer
    B. Error
    Explanation
    The given code will result in an error because the condition inside the while loop is not specified. The while loop requires a condition to be evaluated, and since there is no condition provided (the dot symbol is not a valid condition), it will result in a syntax error.

    Rate this question:

  • 14. 

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

    • A.

      10

    • B.

      Run Time Error

    • C.

      Compilation Error

    • D.

      None of the Above 

    Correct Answer
    B. Run Time Error
    Explanation
    The given code is written in C language. It initializes a variable 'a' with the value 10 and then prints the value of 'a' using the printf function. Since the code does not have any syntax errors, it will compile successfully. However, it will result in a runtime error because the format specifier used in the printf function is incorrect. The correct format specifier for an integer is "%d" but in the code, it is written as "%quot;%d%quot;". This will cause the code to throw a runtime error.

    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.

      Error

    • B.

      No Output

    • C.

      100

    • D.

      None of the Above

    Correct Answer
    A. Error
    Explanation
    The code is giving an error because the function `test` is trying to modify the value of `num.x`, but it is passed by value to the function. This means that the function is working with a copy of `num`, and any changes made to `n.x` inside the function will not affect the original `num.x`. To fix this error, the function `test` should take a pointer to `struct number` as a parameter, allowing it to modify the original `num.x`.

    Rate this question:

  • 16. 

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

    • A.

      0 4

    • B.

      Compile Time Error

    • C.

      0 5

    • D.

      Run Time Error

    Correct Answer
    C. 0 5
    Explanation
    In this code, the variable "a" is assigned the result of the logical AND operation between 0 and the pre-decremented value of "b". Since the value of "b" is initially 5, it is decremented to 4 before the logical AND operation is performed. The logical AND operator returns 0 if any of the operands is 0, otherwise it returns 1. In this case, the result of the logical AND operation is 0 because one of the operands is 0. Therefore, "a" is assigned the value 0. The value of "b" remains 5 because the decrement operation is not assigned to it. Finally, the printf statement prints the values of "a" and "b", which are 0 and 5 respectively.

    Rate this question:

  • 17. 

    Void PrintCount() {  static int Count=1;  printf("%d ",Count);  Count=Count+1; } int  main() {  PrintCount();  PrintCount();  PrintCount();  return 0; }

    • A.

       1 1 1

    • B.

      1 2 3

    • C.

      Compile time error

    • D.

      Run time error

    Correct Answer
    B. 1 2 3
    Explanation
    The function PrintCount is called three times in the main function. The variable Count is declared as a static variable inside the PrintCount function, which means it retains its value between function calls.

    Initially, Count is set to 1. The first time PrintCount is called, it prints the value of Count (which is 1) and then increments it by 1. So the first output is 1.

    The second time PrintCount is called, it prints the value of Count (which is now 2) and then increments it by 1. So the second output is 2.

    The third time PrintCount is called, it prints the value of Count (which is now 3) and then increments it by 1. So the third output is 3.

    Therefore, the correct answer is "1 2 3".

    Rate this question:

  • 18. 

    Void main() { int a,b,c; a+b=c; } What type of error we get

    • A.

      Syntax Error

    • B.

      Semantic Error

    • C.

      Logical Error

    • D.

      Run Time Error

    Correct Answer
    B. Semantic Error
    Explanation
    The given code has a semantic error. In the line "a+b=c;", the assignment operator (=) is used incorrectly. The left side of the assignment operator should be a variable, but in this case, it is an expression (a+b). This violates the syntax rules of the programming language and results in a semantic error.

    Rate this question:

  • 19. 

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

    • A.

      No Output

    • B.

      2K19

    • C.

      QuestCSE

    • D.

      Compilation Error

    Correct Answer
    D. Compilation Error
    Explanation
    The given code will not produce a compilation error. The output will be "2K19". The if statement checks if the value of x is greater than or equal to 10, which is false in this case. Therefore, the code inside the if statement will not be executed. The code outside the if statement will be executed, which is the printf("2K19") statement, resulting in the output "2K19".

    Rate this question:

  • 20. 

    #include<stdio.h> int main() {        int i;        for(i=0;i<=3;i++);         printf("%d",i);         return 0; }

    • A.

      Compilation Error

    • B.

      1 2 3

    • C.

      4

    • D.

      0 1 2 3

    Correct Answer
    C. 4
    Explanation
    The correct answer is 4.

    In this code, there is a for loop that runs from i=0 to i

    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 05, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 26, 2019
    Quiz Created by
    Trouble
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.