iGET

Computer Knowledge - MCQ Practice Questions

Computer Science questions in competitive exams stay close to fundamentals, which is good news if you revise the right five subjects. Coverage includes data structures, algorithms and complexity, operating systems, database management systems, computer networks, and computer organisation. Explanations show the trace or the state table where one helps, since seeing the intermediate steps is what makes the concept stick.

304 questions | 100% Free

Q.1Medium

What will be the output of the following C code?

int main() {
int x = 5;
int *p = &x;
int **q = &p;
printf("%d", **q + 1);
return 0;
}

Q.2Easy

Which of the following correctly describes the difference between malloc() and calloc() in C?

Q.3Medium

What is the output of the following code snippet?

int main() {
char arr[] = "GATE";
char *p = arr;
printf("%d\n", sizeof(arr));
printf("%d", sizeof(p));
return 0;
}

Q.4Hard

Consider a structure with bit fields. What will be the size of the following structure in bytes?

struct demo {
unsigned int a : 5;
unsigned int b : 3;
unsigned int c : 4;
unsigned int d : 7;
};

Q.5Hard

What is the purpose of the volatile keyword in C?

Q.6Easy

Which data structure uses the LIFO (Last In First Out) principle and is commonly used for function call management in programming languages?

Q.7Medium

Which of the following operations has an average time complexity of O(1) in a Hash Table with good hash function and low collision rate?

Q.8Hard

In a B-tree of order m, what is the maximum number of children a non-leaf node can have?

Q.9Medium

Which data structure is most suitable for implementing a priority queue where elements with higher priority need to be dequeued first?

Q.10Easy

What is the output of the following C code?
int x = 5;
printf("%d", x++);

Q.11Easy

Which of the following is the correct syntax to declare a pointer in C?

Q.12Easy

What will be the size of the following array in bytes?
char arr[10];

Q.13Easy

What is the purpose of the 'void' keyword in C?

Q.14Easy

What is the output of the following C code?
int a = 10, b = 20;
int c = (a > b) ? a : b;
printf("%d", c);

Q.15Easy

What does the strlen() function return?

Q.16Medium

What is the output of the following C code?
int x = 5;
int y = ++x + x++;
printf("%d", y);

Q.17Medium

What is the difference between scanf() and gets() functions?

Q.18Medium

What is the correct way to allocate memory for a single integer using malloc()?

Q.19Medium

What is the output of the following C code?
int x = 5;
int *ptr = &x;
printf("%d %d", *ptr, x);

Q.20Medium

What happens when you use the strcpy() function without bounds checking?