1.
It's a simple question that'll be asked in every club.Why do you want to join a club?
2.
What is output?# include <stdio.h> void print(int arr[]){ int n = sizeof(arr)/sizeof(arr[0]); int i; for (i = 0; i < n; i++) printf("%d ", arr[i]);} int main(){ int arr[] = {1, 2, 3, 4, 5, 6, 7, 8}; print(arr); return 0;}
Correct Answer
C. 1
Explanation
The program defines a function called print that takes an array as an argument. Inside the print function, the size of the array is calculated by dividing the total size of the array by the size of each element. Then, a for loop is used to iterate over the elements of the array and print each element. In the main function, an array of integers is declared and initialized with values. The print function is called with this array as an argument. Since the array has 8 elements, the for loop in the print function will iterate 8 times and print each element of the array. Therefore, the output of the program will be 1, 2, 3, 4, 5, 6, 7, 8.
3.
Predict the output of below program:#include int main(){ int arr[5]; // Assume base address of arr is 2000 and size of integer is 32 bit printf("%u %u", arr + 1, &arr + 1); return 0;}
Correct Answer
A. 2004 2020
Explanation
The program prints the memory addresses of two different elements in the array. The expression "arr + 1" gives the address of the second element in the array, which is 2004. The expression "&arr + 1" gives the address of the next memory block after the entire array, which is 2020.
4.
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
Correct Answer
B. 4050
Explanation
The given declaration of a two-dimensional array in C, char a[100][100], indicates that the array has 100 rows and 100 columns. Since the array is stored starting from memory address 0, to find the address of a[40][50], we need to calculate the offset based on the size of each element. In this case, each element is a char, which typically takes 1 byte of memory. Therefore, the offset for 40 rows would be 40 * 100 * 1 = 4000 bytes, and the offset for 50 columns would be 50 * 1 = 50 bytes. Adding these offsets to the base address 0 gives us the address of a[40][50] as 4050.
5.
Output of following program?#include <stdio.h>int main(){ int i = 5; printf("%d %d %d", i++, i++, i++); return 0;}
Correct Answer
D. Compiler Dependent
6.
Consider the following C functionvoid swap (int a, int b){ int temp; temp = a; a = b; b = temp;}
Correct Answer
D. Swap(x,y) cannot be used as the parameters are passed by value
Explanation
The explanation for the given correct answer is that the function swap(x,y) cannot be used because the parameters are passed by value. In C, when a function is called, the values of the arguments are copied into the function parameters. Therefore, any changes made to the parameters inside the function will not affect the original variables that were passed as arguments. In order to modify the original variables, the function should be called using their addresses, as shown in the second option (swap(&x,&y)).
7.
Which is the quickest sorting technique out of the following?(Random dataset)
Correct Answer
A. Merge Sort
Explanation
Merge Sort is the quickest sorting technique out of the given options for a random dataset. Merge Sort has a time complexity of O(n log n), which means it can efficiently sort large datasets. It uses a divide and conquer approach, dividing the dataset into smaller subproblems and then merging them back together in a sorted manner. In comparison, Bubble Sort and Insertion Sort have a time complexity of O(n^2), making them slower for large datasets. Bucket Sort, although efficient for certain datasets, may not be the quickest for a random dataset as it depends on the distribution of the data.
8.
Correct Answer
19
9.
Replace the ? by the correct Mathematics symbol to make the expression true18 ? 12 ? 4 ? 5 = 59Write your answer in the space for the whole expressioneg: 18+12+4+5=59
Correct Answer
18 x 12 / 4 + 5 = 59
10.
If a doctor gives you 3 pills and tells you to take one pill every half hour, how long would it take before all the pills had been taken? How many hours?
Correct Answer
1
Explanation
The question states that a doctor gives you 3 pills and tells you to take one pill every half hour. Since there are 3 pills and you take one pill every half hour, it would take a total of 1 hour to take all the pills.