Skip to main content

Shorting Objective question for c language

1. Which of the following is the correct syntax for using the bubble sort algorithm in C?

a. bubbleSort(int arr[], int n);

b. void bubbleSort(int *arr, int n);

c. int *bubbleSort(int arr[], int n);

d. bubbleSort(int *arr);

Answer: b. void bubbleSort(int *arr, int n);


2.Which sorting algorithm has the best average-case time complexity in C?

a. Bubble Sort

b. Insertion Sort

c. Merge Sort

d. Selection Sort

Answer: c. Merge Sort


3.Which sorting algorithm is not an in-place sorting algorithm in C?

a. Bubble Sort

b. Heap Sort

c. Insertion Sort

d. Quick Sort

Answer: b. Heap Sort


4.Which of the following is the correct time complexity of the Quick Sort algorithm in C?

a. O(n)

b. O(nlogn)

c. O(n^2)

d. O(logn)

Answer: b. O(nlogn)


5.Which of the following is an example of a stable sorting algorithm in C?

a. Bubble Sort

b. Insertion Sort

c. Quick Sort

d. Shell Sort

Answer: b. Insertion

6.Which of the following is not a valid variable type in C?

a) int

b) float

c) char

d) decimal

Answer: d) decimal


7.Which of the following is not a valid C keyword?

a) if

b) while

c) start

d) break

Answer: c) start


8.Which of the following is not a valid way to declare a function in C?

a) int myFunction();

b) void myFunction(void);

c) myFunction(int);

d) int myFunction(int);

Answer: c) myFunction(int);


9.What is the output of the following code?

#include <stdio.h>

int main()

{

   int x = 10, y = 5;

   x = x + y;

   y = x - y;

   x = x - y;

   printf("x = %d, y = %d", x, y);

   return 0;

}

a) x = 5, y = 10

b) x = 10, y = 5

c) x = 15, y = 5

d) x = 5, y = 15


Answer: b) x = 10, y = 5


10.What is the output of the following code?

#include <stdio.h>

int main()

{

   int x = 10, y = 5;

   int *p1 = &x, *p2 = &y;

   *p1 = *p2;

   printf("x = %d, y = %d", x, y);

   return 0;

}

a) x = 5, y = 10

b) x = 10, y = 5

c) x = 5, y = 5

d) x = 10, y = 10


Answer: c) x =A 5, y = 5


11.Which of the following is not a valid way to initialize an array in C?

a) int arr[] = {1, 2, 3};

b) int arr[3] = {1, 2, 3};

c) int arr[3] = {1, 2};

d) int arr[3] = {0};

Answer: c) int arr[3] = {1, 2};


12.Which of the following is not a valid way to declare a pointer in C?

a) int *p;

b) float *p;

c) char *p;

d) int **p;

Answer: d) int **p;


13.What is the output of the following code?

#include <stdio.h>

int main()

{

   int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

   printf("%d", arr[1][2]);

   return 0;

}

a) 1

b) 2

c) 6

d) 8


Answer: c) 6

14.Which of the following is a sorting algorithm in C?

a) binary search

b) merge sort

c) breadth-first search

d) depth-first search

Answer: b) merge sort


15.Which of the following is not a stable sorting algorithm in C?

a) bubble sort

b) selection sort

c) quick sort

d) insertion sort

Answer: c) quick sort


16.Which of the following sorting algorithms has a worst-case time complexity of O(n^2) in C?

a) bubble sort

b) merge sort

c) heap sort

d) radix sort

Answer: a) bubble sort


17.Which of the following is a comparison-based sorting algorithm in C?

a) counting sort

b) bucket sort

c) quick sort

d) radix sort

Answer: c) quick sort


18.Which of the following is an in-place sorting algorithm in C?

a) quick sort

b) merge sort

c) heap sort

d) insertion sort

Answer: a) quick sort


19.Which of the following is a stable sorting algorithm in C?

a) quick sort

b) heap sort

c) insertion sort

d) shell sort

Answer: c) insertion sort


20.Which of the following is an external sorting algorithm in C?

a) quick sort

b) merge sort

c) bubble sort

d) selection sort

Answer: b) merge sort


21.Which of the following is not a comparison-based sorting algorithm in C?

a) counting sort

b) quick sort

c) heap sort

d) insertion sort

Answer: a) counting sort


22.Which of the following is a recursive sorting algorithm in C?

a) bubble sort

b) selection sort

c) insertion sort

d) merge sort

Answer: d) merge sort


23.Which of the following sorting algorithms is typically used for sorting linked lists in C?

a) bubble sort

b) selection sort

c) insertion sort

d) merge sort

Answer: d) merge sort

Comments

Popular posts from this blog

Most importance question with Answers in C++

1. Write the shorts notes on Garbage collection. Ans.  Garbage collection in C++ isn't native to the language; it relies on manual memory management using constructs like new and delete . However, some third-party libraries or smart pointers like std::shared_ptr and std::unique_ptr offer automated memory management. C++11 introduced smart pointers, reducing manual memory handling but lacking the automatic garbage collection found in languages like Java or Python. 2. What is multiple heritance? Ans. Multiple inheritance in C++ enables a class to inherit attributes and behaviors from more than one base class. It allows a derived class to access features from multiple parent classes, fostering complex class hierarchies but potentially causing issues like the diamond problem due to ambiguous member access. 3. What do you mean by operator overloading ? Ans. Operator overloading in C++ allows defining custom behaviors for operators like +, -, *, etc., for user-defined types. It enable

Course Name: Operating System[Objective QUESTION]

  Course Code: BCA-402 Course Name: Operating System UNIT-I: Introduction What is an operating system? a) A hardware component b) A system software that manages hardware and software resources c) An application software d) A programming language Answer: b) A system software that manages hardware and software resources Which of the following is a characteristic of simple batch systems? a) Real-time processing b) Interactive processing c) Jobs are processed in batches without user interaction d) Distributed processing Answer: c) Jobs are processed in batches without user interaction Multi-programmed batch systems are designed to: a) Handle one task at a time b) Improve CPU utilization by running multiple programs simultaneously c) Execute programs in a sequential manner d) Only manage system files Answer: b) Improve CPU utilization by running multiple programs simultaneously Time-sharing systems are characterized by: a) Batch processing b) Real-time processing c) Allowing multiple users