Hardest C Programming Trivia Quiz! Test

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 Sumakshi Chauhan
S
Sumakshi Chauhan
Community Contributor
Quizzes Created: 1 | Total Attempts: 352
Questions: 40 | Attempts: 353

SettingsSettingsSettings
Hardest C Programming Trivia Quiz! Test - Quiz

.


Questions and Answers
  • 1. 

    When a computer is first turned on or restarted, a special type of absolute loader called ____ is executed

    • A.

      Compile and Go loader

    • B.

      Boot loader

    • C.

      Bootstrap loader

    • D.

      Relating loader

    Correct Answer
    C. Bootstrap loader
    Explanation
    When a computer is first turned on or restarted, a special type of absolute loader called a bootstrap loader is executed. The bootstrap loader is responsible for initializing the computer's hardware, loading the operating system into memory, and starting the execution of the operating system. It is a critical component in the booting process of a computer, as it sets up the necessary environment for the computer to function properly.

    Rate this question:

  • 2. 

    The time factor when determining the efficiency of algorithm is measured by

    • A.

      Counting microseconds

    • B.

      Counting the number of key operations

    • C.

      Counting the number of statements

    • D.

      Counting the kilobytes of algorithm

    Correct Answer
    B. Counting the number of key operations
    Explanation
    The time factor when determining the efficiency of an algorithm is measured by counting the number of key operations. This is because the efficiency of an algorithm is often determined by the number of basic operations it performs, such as comparisons, assignments, and arithmetic operations. By counting the number of key operations, we can get an idea of how efficient the algorithm is and compare it to other algorithms. Counting microseconds, the number of statements, or the kilobytes of the algorithm would not provide an accurate measure of the algorithm's efficiency.

    Rate this question:

  • 3. 

    Which of the following case does not exist in complexity theory

    • A.

      Best case

    • B.

      Worst case

    • C.

      Average case

    • D.

      Null case

    Correct Answer
    D. Null case
    Explanation
    The null case does not exist in complexity theory. In complexity theory, we analyze the performance of algorithms in different scenarios, such as the best case, worst case, and average case. The null case, however, does not represent any specific scenario or input for the algorithm. It is not a commonly considered case in complexity analysis.

    Rate this question:

  • 4. 

    The Worst case occur in linear search algorithm when

    • A.

      Item is somewhere in the middle of the array

    • B.

      Item is not in the array at all

    • C.

      Item is the last element in the array

    • D.

      Item is the last element in the array or is not there at all

    Correct Answer
    D. Item is the last element in the array or is not there at all
    Explanation
    In the worst case scenario for a linear search algorithm, the item being searched for is either the last element in the array or it is not present in the array at all. In both cases, the algorithm will have to iterate through the entire array before determining that the item is not there or finding it at the end. This results in the maximum number of comparisons being made, making it the worst case for the linear search algorithm.

    Rate this question:

  • 5. 

    Linked lists are best suited

    • A.

      For relatively permanent collections of data

    • B.

      for the size of the structure and the data in the structure are constantly changing

    • C.

      For both of above situation

    • D.

      For none of above situation

    Correct Answer
    B. for the size of the structure and the data in the structure are constantly changing
    Explanation
    Linked lists are best suited for situations where the size of the structure and the data in the structure are constantly changing. Unlike arrays, linked lists can dynamically allocate memory as needed, allowing for efficient insertion and deletion of elements. This makes linked lists a good choice when the size of the data structure needs to be flexible and can change frequently.

    Rate this question:

  • 6. 

    Multiprogramming systems:

    • A.

      Are easier to develop than single programming systems

    • B.

      Execute each job faster

    • C.

      Execute more jobs in the same time period

    • D.

      Are used only one large mainframe computers.

    Correct Answer
    C. Execute more jobs in the same time period
    Explanation
    Multiprogramming systems are designed to execute multiple jobs simultaneously, allowing for increased efficiency and productivity. By running multiple jobs concurrently, these systems can process a higher number of jobs within the same time period compared to single programming systems. This allows for better resource utilization and improved throughput. Additionally, multiprogramming systems are not limited to running on large mainframe computers, as they can also be implemented on smaller systems such as personal computers or servers.

    Rate this question:

  • 7. 

    Given the language L = {ab, aa, baa}, which of the following strings are in L*? (Multiple correct type)  

    • A.

      Abaabaaabaa

    • B.

      Aaaabaaaa

    • C.

      Baaaaabaaaab

    • D.

      Baaaaabaa

    Correct Answer(s)
    A. Abaabaaabaa
    B. Aaaabaaaa
    D. Baaaaabaa
    Explanation
    (You can select more than one option)

    Rate this question:

  • 8. 

    Which one of the following is an example of storage class in C?

    • A.

      Int and float

    • B.

      Extern

    • C.

      Both 1 & 2

    • D.

      Neither 1 nor 2

    Correct Answer
    B. Extern
    Explanation
    The correct answer is "extern" because "extern" is a storage class in C. It is used to declare a variable that is defined in another file or module. This allows the variable to be accessed by multiple files or modules in a program. The other options, "int and float," are not storage classes but rather data types in C.

    Rate this question:

  • 9. 

    Which one of the following is the correct way of declaring main() function when it receives command line arguments?

    • A.

      Main(int argc, char argv)

    • B.

      Main(char argv[ ], int *argc)

    • C.

      Main(char* argv[ ],int argc)

    • D.

      Main(int argc,char* argv[ ])

    Correct Answer
    D. Main(int argc,char* argv[ ])
    Explanation
    The correct way of declaring the main() function when it receives command line arguments is "main(int argc, char* argv[])". In this declaration, "argc" is an integer that represents the number of command line arguments passed to the program, and "argv" is an array of strings that holds the actual arguments.

    Rate this question:

  • 10. 

    Which of the following is a correct way of defining a symbolic constant pie in C

    • A.

      # define pie = 22/7

    • B.

      #define pie 22/7

    • C.

      #define pie= 3.142

    • D.

      # Define pie 22/7

    Correct Answer
    B. #define pie 22/7
    Explanation
    The correct way of defining a symbolic constant pie in C is by using the #define directive followed by the name of the constant (in this case, "pie") and its value (22/7). This creates a constant that can be used throughout the program and cannot be changed.

    Rate this question:

  • 11. 

    What should be the output of the following C code :  #include <stdio.h> int main() {   static int y;   printf(“%d\n”, y);   return 0;  }

    • A.

      0

    • B.

      Run-time error

    • C.

      Undefined

    • D.

      Compilation error

    Correct Answer
    A. 0
    Explanation
    The code declares a static integer variable "y" but does not initialize it. In C, static variables are automatically initialized to zero. Therefore, when the code tries to print the value of "y", it will be 0.

    Rate this question:

  • 12. 

    Consider the following pseudo-code. Assume that IntQueue is a class implementing an integer queue, enqueue() and dequeue() are member functions for inserting and deleting values to/from a queue object respectively.  What does the function fun() do? void fun(int n) {   IntQueue q;   q.enqueue(0);   q.enqueue(1);   for (int i = 0; i < n; i++)   {     int a = q.dequeue();     int b = q.dequeue();     q.enqueue(b);     q.enqueue(a + b);     print(a);   } }

    • A.

      Prints numbers from 0 to n-1

    • B.

      Prints numbers from n-1 to 0

    • C.

      Prints first n Fibonacci numbers

    • D.

      Prints first n Fibonacci numbers in reverse order.

    Correct Answer
    C. Prints first n Fibonacci numbers
    Explanation
    The function fun() implements the Fibonacci sequence. It starts by enqueuing the values 0 and 1. Then, in the for loop, it dequeues two values, adds them together, and enqueues the sum and the second dequeued value. This process continues for n iterations. Finally, it prints the first dequeued value in each iteration, which represents the Fibonacci numbers. Therefore, the function prints the first n Fibonacci numbers.

    Rate this question:

  • 13. 

    The output of the below C code is : #include <stdio.h> float func(int aa, float bb) {   return ((float)aa + bb); } int main() {   int a;   a = func(10, 3.14);   printf("%d\n", a);   return 0; }

    • A.

      13.14

    • B.

      13

    • C.

      13.00

    • D.

      None of the above

    Correct Answer
    B. 13
    Explanation
    The output of the code is 13 because the function func takes an integer and a float as arguments and returns their sum as a float. In the main function, the function func is called with arguments 10 and 3.14. The result of the function call is assigned to the integer variable a. However, since the return type of func is a float, the decimal part of the sum (0.14) is truncated when it is assigned to the integer variable a. Therefore, the value of a is 13.

    Rate this question:

  • 14. 

    What is the output of the following program? #include<stdio.h> void main() { struct { int x;} var = {5}, *p = &var; printf("%d %d %d", var.x, p->x, (*p).x); }

    • A.

      5 5 5

    • B.

      5 5  garbage value

    • C.

      5 5 0 

    • D.

      Compile Error

    Correct Answer
    A. 5 5 5
    Explanation
    The program declares a structure variable 'var' of type struct {int x;} and initializes it with the value 5. It also declares a pointer variable 'p' of the same type and assigns it the address of 'var'. The printf statement then prints the value of 'var.x', 'p->x', and '(*p).x', which are all 5. Therefore, the output of the program is "5 5 5".

    Rate this question:

  • 15. 

    What is the output of this C code? #include <stdio.h> void main() {   int y = 97;   int x = y++;   printf("x is %d", x); }  

    • A.

      X is 97

    • B.

      X is 98

    • C.

      X is 99

    • D.

      Compilation Error

    Correct Answer
    A. X is 97
    Explanation
    In this code, the variable y is assigned the value 97. Then, the variable x is assigned the value of y, which is 97, and then the value of y is incremented by 1. Finally, the value of x is printed, which is 97.

    Rate this question:

  • 16. 

    What is the output of the below C code? #include <stdio.h> void main() {   char *s = "hello";   char *p = s;   printf("%p %p", p, s); }

    • A.

      Different addresses are printed

    • B.

      Same address is printed separated by a space

    • C.

      Compilation error

    • D.

      Nothing

    Correct Answer
    B. Same address is printed separated by a space
    Explanation
    The code declares a character pointer variable 's' and assigns it the memory address of the string "hello". Then, another character pointer variable 'p' is declared and assigned the same memory address as 's'. Finally, the printf function is used to print the memory addresses of 'p' and 's' separated by a space. Since 'p' and 's' both point to the same memory address, the output will be the same address printed twice, separated by a space.

    Rate this question:

  • 17. 

    What is common in three different types of traversals (Inorder, Preorder, and Postorder)?

    • A.

      Root is visited before right subtree

    • B.

      Left subtree is always visited before right subtree

    • C.

      Root is visited after left subtree

    • D.

      All of the above

    Correct Answer
    B. Left subtree is always visited before right subtree
    Explanation
    In all three types of traversals (Inorder, Preorder, and Postorder), the left subtree is always visited before the right subtree. This ensures that the elements in the left subtree are processed before moving on to the elements in the right subtree. This order is consistent across all three traversal methods.

    Rate this question:

  • 18. 

    Find out the correct statement for the following program #include "stdio.h" int * arrPtr[5]; int main() { if(*(arrPtr+2) == *(arrPtr+4)) { printf("Equal!"); } else { printf("Not Equal"); } return 0; }

    • A.

      Compile Error

    • B.

      It’ll always print Equal.

    • C.

      It’ll always print Not Equal.

    • D.

      Since elements of arrPtr aren’t initialized in the program, it’ll print either Equal or Not Equal.

    Correct Answer
    B. It’ll always print Equal.
    Explanation
    The correct answer is "It'll always print Equal." This is because the program declares an array of integer pointers, but does not initialize any of the pointers in the array. When comparing *(arrPtr+2) and *(arrPtr+4), both pointers are uninitialized and therefore have indeterminate values. According to the C standard, comparing two indeterminate values with the == operator results in undefined behavior. However, in most implementations, the comparison will evaluate to true and "Equal!" will be printed.

    Rate this question:

  • 19. 

    #include <stdio.h> void f(int *p, int *q) {   p = q;   *p = 2; } int i = 0, j = 1; int main() {   f(&i, &j);   printf("%d%d\n", i, j);   return 0; }

    • A.

      22

    • B.

      21

    • C.

      01

    • D.

      02

    Correct Answer
    D. 02
    Explanation
    The function f takes two pointers as arguments. Inside the function, the pointer p is assigned the value of pointer q. Then, the value at the memory location pointed to by p (which is the memory location of j) is changed to 2. In the main function, the function f is called with the addresses of i and j as arguments. After the function call, the values of i and j are printed. Since the value of j was changed inside the function, the output is 02.

    Rate this question:

  • 20. 

    Is it possible to create a doubly linked list using only one pointer with every node?

    • A.

      Not Possible

    • B.

      Yes, possible by storing XOR of addresses of previous and next nodes.

    • C.

      Yes, possible by storing XNOR of addresses of previous and next nodes.

    • D.

      Yes, possible by storing XOR of the current node and previous node  

    Correct Answer
    B. Yes, possible by storing XOR of addresses of previous and next nodes.
    Explanation
    It is possible to create a doubly linked list using only one pointer with every node by storing the XOR of addresses of the previous and next nodes. This can be achieved by performing bitwise XOR operation on the addresses of the previous and next nodes and storing the result in the current node. This allows traversal in both directions by XORing the current node's address with the address stored in the previous or next node.

    Rate this question:

  • 21. 

    The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of the following is the postorder traversal sequence of the same tree?

    • A.

      10, 20, 15, 23, 25, 35, 42, 39, 30

    • B.

      15, 10, 25, 23, 20, 42, 35, 39, 30

    • C.

      15, 20, 10, 23, 25, 42, 35, 39, 30

    • D.

      15, 10, 23, 25, 20, 35, 42, 39, 30

    Correct Answer
    D. 15, 10, 23, 25, 20, 35, 42, 39, 30
    Explanation
    The given preorder traversal sequence of the binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. To find the postorder traversal sequence, we need to start from the root and then recursively visit the left subtree and the right subtree. From the given sequence, we can observe that the root of the tree is 30. The left subtree will have elements less than 30 and the right subtree will have elements greater than 30. By following this pattern, we can determine that the postorder traversal sequence is 15, 10, 23, 25, 20, 35, 42, 39, 30.

    Rate this question:

  • 22. 

    What is the return type of malloc() or calloc() ?

    • A.

      Void *

    • B.

      A pointer of allocated memory type

    • C.

      Void **

    • D.

      Int *

    Correct Answer
    A. Void *
    Explanation
    The return type of malloc() or calloc() is void *. This means that these functions return a pointer to allocated memory, which can be of any data type. The void * type is a generic pointer type that can be cast to any other pointer type as needed.

    Rate this question:

  • 23. 

    Predict the output of the below program: #include <stdio.h> #define EVEN 0 #define ODD 1 int main() { int i = 3; switch (i & 1) { case EVEN: printf("Even"); break; case ODD: printf("Odd"); break; default: printf("Default"); } return 0; }

    • A.

      Even

    • B.

      Odd

    • C.

      Default

    • D.

      Compile-time error

    Correct Answer
    B. Odd
    Explanation
    The program defines two constants, EVEN with a value of 0 and ODD with a value of 1. It then initializes a variable i with a value of 3. The program then uses a bitwise AND operator to check if i is even or odd. Since 3 & 1 is equal to 1, the case ODD is executed and "Odd" is printed as the output.

    Rate this question:

  • 24. 

    Consider the following C declaration struct { short s[5]; union { float y; long z; }u; } t; Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes, and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is

    • A.

      22 bytes

    • B.

      14 bytes

    • C.

      18 bytes

    • D.

      10 bytes

    Correct Answer
    C. 18 bytes
    Explanation
    The memory requirement for variable t can be calculated by adding up the memory occupied by each member of the struct. The short array s[5] occupies 2 bytes per element, so it occupies a total of 10 bytes. The union u can only occupy the memory of its largest member, which is the long z that occupies 8 bytes. Therefore, the total memory requirement for variable t is 10 + 8 = 18 bytes.

    Rate this question:

  • 25. 

    What is the time complexity to search for an element using hashing.

    • A.

      O(n)

    • B.

      O(n log(n))

    • C.

      O(1)

    • D.

      O(log n)

    Correct Answer
    C. O(1)
    Explanation
    The time complexity to search for an element using hashing is O(1). This is because hashing allows for constant time access to elements in a data structure, regardless of the size of the data set. The element's key is hashed to a specific index in the hash table, and the element can be directly accessed at that index. Therefore, the time taken to search for an element using hashing does not depend on the number of elements in the data structure, resulting in a constant time complexity of O(1).

    Rate this question:

  • 26. 

    Output of following program? #include<stdio.h>  int main() { int a[] = {1, 2, 3, 4, 5, 6}; int *ptr = (int*)(&a+1); printf("%d ", *(ptr-1) ); return 0; }

    • A.

      1

    • B.

      2

    • C.

      6

    • D.

      Runtime Error

    Correct Answer
    C. 6
    Explanation
    The program creates an array "a" with elements 1, 2, 3, 4, 5, 6. The variable "ptr" is assigned the address of the end of the array "a" using the expression (&a+1). Then, the program prints the value at the address (ptr-1), which is the last element of the array "a", which is 6.

    Rate this question:

  • 27. 

    A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X read x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?

    • A.

      -2

    • B.

      -1

    • C.

      1

    • D.

      2

    Correct Answer
    D. 2
    Explanation
    The maximum possible value of x after all processes complete execution is 2. This is because the processes W and X increment the value of x by 1, while the processes Y and Z decrement the value of x by 2. Since there are two processes incrementing and two processes decrementing, the net effect on x is an increment of 2. Therefore, the maximum possible value of x is 2.

    Rate this question:

  • 28. 

    What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a tree with a single node is 0.

    • A.

      2

    • B.

      3

    • C.

      4

    • D.

      5

    Correct Answer
    A. 2
    Explanation
    The maximum height of any AVL-tree with 7 nodes is 2. In an AVL-tree, the height is defined as the number of edges in the longest path from the root to a leaf node. Since the height of a tree with a single node is 0, and an AVL-tree is balanced such that the heights of its left and right subtrees differ by at most 1, the maximum height of an AVL-tree with 7 nodes can be achieved when the tree is perfectly balanced. In this case, the tree would have 3 levels, with the root node at level 0, two child nodes at level 1, and four leaf nodes at level 2. Therefore, the maximum height is 2.

    Rate this question:

  • 29. 

    Which of the following is TRUE?

    • A.

      The cost of searching an AVL tree is θ(log n) but that of a binary search tree is O(n)

    • B.

      The cost of searching an AVL tree is θ(log n) but that of a complete binary tree is θ(n log n)

    • C.

      The cost of searching a binary search tree is O(log n ) but that of an AVL tree is θ(n)

    • D.

      The cost of searching an AVL tree is θ(n log n) but that of a binary search tree is O(n)

    Correct Answer
    D. The cost of searching an AVL tree is θ(n log n) but that of a binary search tree is O(n)
  • 30. 

    Consider the following declaration of a ‘two-dimensional array in C: char a[100][100]; Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 0, the address of a[40][50] is:

    • A.

      4040

    • B.

      4050

    • C.

      5040

    • D.

      5050

    Correct Answer
    B. 4050
    Explanation
    In a two-dimensional array, the elements are stored in a contiguous manner. In this case, the array is declared as char a[100][100], meaning it has 100 rows and 100 columns. Since each element in the array is of type char, which occupies 1 byte of memory, the total size of the array is 100 * 100 * 1 = 10,000 bytes.

    To find the address of a specific element, we need to consider the row and column indices. In this case, a[40][50] refers to the element in the 40th row and 50th column. Since each row has 100 elements, the address of the element can be calculated as follows:

    Address = Base Address + (Row Index * Number of Columns + Column Index) * Size of Each Element
    = 0 + (40 * 100 + 50) * 1
    = 0 + (4000 + 50)
    = 0 + 4050
    = 4050

    Therefore, the address of a[40][50] is 4050.

    Rate this question:

  • 31. 

    The output of the following C program is : #include <stdio.h> #include <string.h> int main() {     char p[20];     char *s = "string";     int length = strlen(s);     int i;          for(i = 0;i < length;i++) {         p[i] = s[length-1-i];     }          printf("%s",p); }

    • A.

      Compilation error

    • B.

      Gnirt

    • C.

      String

    • D.

      Gnirts

    Correct Answer
    D. Gnirts
    Explanation
    The program first declares a character array `p` with a size of 20. It then declares a pointer `s` that points to the string "string". The program calculates the length of the string using the `strlen` function and stores it in the variable `length`.

    Next, the program enters a loop that iterates `length` times. Inside the loop, it assigns the characters of `s` in reverse order to the array `p`.

    Finally, the program prints the contents of `p`, which is "gnirts". Therefore, the correct answer is "gnirts".

    Rate this question:

  • 32. 

    Which of the following requires a device driver?

    • A.

      Register

    • B.

      Cache

    • C.

      Main memory

    • D.

      Disk

    Correct Answer
    D. Disk
    Explanation
    A device driver is a software program that allows the operating system to communicate with a specific hardware device. In this case, a disk refers to a storage device such as a hard drive or solid-state drive. Since disks are hardware devices, they require a device driver to enable the operating system to interact with them and perform tasks such as reading and writing data.

    Rate this question:

  • 33. 

    An operating system uses the Shortest Remaining Time First (SRTF) process scheduling algorithm. Consider the arrival times and execution times for the following processes: Process Execution time Arrival time P1 20 0 P2 25 15 P3 10 30 P4 15 45 What is the total waiting time for process P2?

    • A.

      5

    • B.

      15

    • C.

      40

    • D.

      55

    Correct Answer
    B. 15
    Explanation
    The total waiting time for process P2 is 15. This is because P2 has an arrival time of 15 and an execution time of 25. Since P2 arrives before P3 and P4, it will be executed first. Therefore, it does not have to wait for any other process to finish before it can start executing. Hence, the waiting time for P2 is 0.

    Rate this question:

  • 34. 

    Which of the following indicates the end of file in C ?

    • A.

      Feof()

    • B.

      EOF

    • C.

      Both feof() and EOF

    • D.

      None of the mentioned

    Correct Answer
    C. Both feof() and EOF
    Explanation
    Both feof() and EOF are used to indicate the end of a file in C. The feof() function is used to check if the end of file indicator has been set, while EOF is a constant that represents the end of file. Using both feof() and EOF together provides a comprehensive way to determine if the end of file has been reached in a C program.

    Rate this question:

  • 35. 

    If a function's return type is not explicitly defined then it defaults to ………. (in C).

    • A.

      Int

    • B.

      Float

    • C.

      Void

    • D.

      Error

    Correct Answer
    A. Int
    Explanation
    In C, if a function's return type is not explicitly defined, it defaults to "int". This means that if the return type of a function is not specified using the keyword "void" or any other data type, the compiler assumes that the function will return an integer value.

    Rate this question:

  • 36. 

    The worst case running time complexity of Euclid's GCD algorithm is :

    • A.

      O(n)

    • B.

      O(n log(n))

    • C.

      O(log n)

    • D.

      O(n^2)

    Correct Answer
    C. O(log n)
    Explanation
    Euclid's GCD algorithm is an efficient method to find the greatest common divisor of two numbers. It uses the property that the GCD of two numbers is the same as the GCD of the smaller number and the remainder when the larger number is divided by the smaller number. In each iteration, the algorithm reduces the problem size by dividing the larger number by the smaller number. This process continues until the remainder becomes zero, which indicates that the smaller number is the GCD. The number of iterations required to reach this point is proportional to the number of digits in the smaller number, which can be represented as O(log n). Therefore, the worst-case running time complexity of Euclid's GCD algorithm is O(log n).

    Rate this question:

  • 37. 

    Which of the following C string functions can be used for comparing two strings :

    • A.

      Strlen()

    • B.

      Strcmp()

    • C.

      Strcat()

    • D.

      Strcpy()

    Correct Answer
    B. Strcmp()
    Explanation
    The strcmp() function is used for comparing two strings in C. It returns an integer value based on the comparison. If the strings are equal, it returns 0. If the first string is greater than the second string, it returns a positive value. If the first string is less than the second string, it returns a negative value. Therefore, strcmp() is the correct C string function for comparing two strings.

    Rate this question:

  • 38. 

    Non-recursive implementation of Depth First Search algorithm uses which data structure :

    • A.

      List

    • B.

      Stack

    • C.

      Queue

    • D.

      None

    Correct Answer
    B. Stack
    Explanation
    The non-recursive implementation of the Depth First Search algorithm uses a stack data structure. In this implementation, the algorithm starts at a given node and explores as far as possible along each branch before backtracking. The stack is used to keep track of the nodes that still need to be explored. The algorithm pops a node from the stack, visits it, and pushes its unvisited neighbors onto the stack. This process continues until the stack is empty, indicating that all nodes have been visited. Therefore, the correct answer is Stack.

    Rate this question:

  • 39. 

    Regular expression for all strings starts with ab and ends with bba is. 

    • A.

      Aba*b*bba

    • B.

      Ab(ab)*bba

    • C.

      Ab(a+b)*bba

    • D.

      All of the mentioned

    Correct Answer
    C. Ab(a+b)*bba
    Explanation
    The regular expression "ab(a+b)*bba" represents all strings that start with "ab" and end with "bba". The "ab" in the beginning ensures that the string starts with "ab", followed by zero or more occurrences of "a" or "b" (represented by "(a+b)*"), and finally ends with "bba". This regular expression covers all possible combinations of characters that satisfy the given condition.

    Rate this question:

  • 40. 

    If the time quantum of Round robin algorithm is very large, then it is equivalent to :

    • A.

      Lottery scheduling

    • B.

      FCFS algorithm

    • C.

      Shortest Job Next 

    • D.

      None of the above

    Correct Answer
    B. FCFS algorithm
    Explanation
    If the time quantum of the Round Robin algorithm is very large, it means that each process is given a large amount of time to execute before being preempted. In this case, the Round Robin algorithm behaves similar to the First-Come-First-Serve (FCFS) algorithm, where the processes are executed in the order they arrive. Therefore, if the time quantum is very large, the Round Robin algorithm is equivalent to the FCFS algorithm.

    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 31, 2019
    Quiz Created by
    Sumakshi Chauhan
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.