Question 1
Predict the output?
int fun(char *str1)
{
char *str2 = str1;
while (*++str1)
;
return (str1 - str2);
}
int main()
{
char *str = "GeeksQuiz";
printf("%d", fun(str));
return 0;
}
10
9
8
Random Number
Question 2
What will be the output of the following program?
#include <stdio.h>
int main() {
int a = 10, b = 20, c;
c = scanf("%d %d", &a, &b);
printf("%d %d %d\n", a, b, c);
return 0;
}
User Input: 30 40
30 40 2
10 20 2
30 40 1
Compilation error
Question 3
Question 4
Question 5
What is the time complexity of following function fun()? Assume that log(x) returns log value in base 2.
void fun(int n)
{
int i, j;
for (i=1; i<=n; i++)
for (j=1; j<=log(i); j++)
printf("GeeksforGeeks");
}
Θ(n)
Θ(nLogn)
Θ(n^2)
Θ(n^2(Logn))
Question 6
Question 7
S1 : Random page replacement algorithm (where
a page chosen at random is replaced)
suffers from Belady’s anomaly.
S2 : Random CPU scheduling algorithm
suffers from convoy effect.
Which of the following is CORRECT?
Question 8
Question 9
int fun()
{
static int num = 16;
return num--;
}
int main()
{
for(fun(); fun(); fun())
printf("%d ", fun());
return 0;
}
Infinite loop
13 10 7 4 1
15 12 8 5 2
14 11 8 5 2
Question 10
Algorithms Design Paradigms
(P) Dijkastra’s Algorithm (i) Divide and Conquer
(Q) Strassen’s Matrix Multiplication (ii) Greedy
(R) Fibonacci numbers (iii) Dynamic Programming
Match the algorithm to design paradigms they are based on:There are 62 questions to complete.