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

VALUE OF TIME

Time is very precious.  We should not waste time.  Once time is lost, it is lost forever.  If you waste time, time will waste you. Money that has been spent can be recovered but not with time.  Time that once elapsed has passed and is over.  Almost everything in the world can be bought, but time lost cannot be bought.When a second has elapsed, that second moves from the present to the past.  If you have not made proper use of that which was in the present, then that second is wasted, it is destroyed and becomes the past.  No matter how much effort or distraction, that past cannot be brought back.If you want to achieve success in life, use your time properly.  take care of the present and Make full use of it. That's all Thank you ❤️

What is external storage class?

Ans . External variables are declared outside all functions,i.e. in the beginning of the program file. As all the functions will be defined after these variables declarations , so these variables are visible to all functions in a program file .

Meaning of accounting

  Meaning of accounting :  A ccounting is  the process of keeping track of an organization's financial transactions and records, and summarizing and communicating this information to relevant parties, such as investors ,creditors, and managers. It helps organizations to manage their finances effectively and make informed decisions about their business activities.