Question 1
#include <stdio.h>
#include <stdarg.h>
int fun(int n, ...)
{
int i, j = 1, val = 0;
va_list p;
va_start(p, n);
for (; j < n; ++j)
{
i = va_arg(p, int);
val += i;
}
va_end(p);
return val;
}
int main()
{
printf("%d\\n", fun(4, 1, 2, 3));
return 0;
}
Question 2
Consider the following C - code :
#include <stdio.h>
int foo(int a)
{
printf("%d",a);
return 0;
}
int main()
{
foo;
return 0;
}
It’ll result in compile error because foo is used without parentheses.
No compile error and some garbage value would be passed to foo function. This would make foo to be executed with output “garbage integer”.
No compile error but foo function wouldn’t be executed. The program wouldn\'t print anything.
No compile error and ZERO (i.e. 0) would be passed to foo function. This would make foo to be executed with output 0.
Question 3
#include "stdio.h"
int main()
{
int a = 10;
int b = 15;
printf("=%d",(a+1),(b=a+2));
printf(" %d=",b);
return 0;
}
Question 4
I. Program Counter II. Stack III. Registers IV. Address space
Question 5
Consider the set of processes with arrival time(in milliseconds), CPU burst time (in milliseconds), and priority(0 is the highest priority) shown below. None of the processes have I/O burst time.
The waiting time (in milliseconds) of process P1 using preemptive priority scheduling algorithm is ____.
Question 6
Consider a link with packet loss probability of 0.2. What is the expected number of transmissions it would take to transfer 200 packets given that the stop and wait protocol is used?
125
250
225
150
Question 7
Question 8
Match the following:
Which of the following option is correct?
Question 9
Question 10
Huffman coding is a lossless data compression algorithm. The most frequent character gets the smallest code and the least frequent character gets the largest code. Consider the following statements regarding Huffman coding algorithm?
S1 : The time complexity of the Huffman algorithm is O(nlogn). Using a heap to store the weight of each tree, each iteration requires O(logn) time to determine the cheapest weight and insert the new weight. There are O(n) iterations, one for each item.
S2 : If the input array is sorted, there exists a linear time algorithm.
S3 : A divide-and-conquer approach might have us asking which characters should appear in the left and right subtrees and trying to build the tree from the top down. As with the optimal binary search tree, this will lead to to an exponential time algorithm.
Which of the following option is correct?
Statement S1 is correct, Statements S2 and S3 are not correct.
Statements S1 and S2 are correct and statement S3 is not correct.
Statements S2 and S3 are correct and statement S1 is not correct.
All statements S1, S2, and S3 are correct.
There are 64 questions to complete.