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

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 us...

Course Name: Computer Graphics & Multimedia Application (BCA-401)

  Course Name: Computer Graphics & Multimedia Application (BCA-401) UNIT-I: Introduction Which of the following is an advantage of interactive graphics? a) Increased computational complexity b) Static visualization c) Enhanced user interaction d) Limited user feedback Answer: c) Enhanced user interaction Which of these is a representative use of computer graphics? a) Database management b) Spreadsheet calculations c) CAD (Computer-Aided Design) d) Text editing Answer: c) CAD (Computer-Aided Design) Computer graphics applications can be classified into which of the following? a) Scientific and business applications b) Art and entertainment applications c) Both a and b d) Neither a nor b Answer: c) Both a and b The development of hardware and software for computer graphics involves: a) Only hardware advancements b) Only software advancements c) Both hardware and software advancements d) None of the above Answer: c) Both hardware and software advancements What is the first step in...

In c, Array objective question with option

1. What is an array in C? a) A collection of similar data items stored in contiguous memory locations. b) A collection of different data items stored in non-contiguous memory locations. c) A collection of similar data items stored in non-contiguous memory locations. d) A collection of different data items stored in contiguous memory locations. Answer: a) A collection of similar data items stored in contiguous memory locations. 2.What is the syntax to declare an array in C? a) dataType arrayName[arraySize]; b) dataType arraySize[arrayName]; c) arrayName[arraySize] dataType; d) arraySize[arrayName] dataType; Answer: a) dataType arrayName[arraySize]; 3.How do you access the first element of an array in C? a) arrayName[0]; b) arrayName[1]; c) arrayName[-1]; d) arrayName[first]; Answer: a) arrayName[0]; 4.What is the index of the last element of an array in C? a) arraySize; b) arraySize - 1; c) arraySize + 1; d) arraySize * 2; Answer: b) arraySize - 1; 5.Can you change the size of an array ...