Sunteți pe pagina 1din 6

CodeWhack Round 1

Participant Name :
Contact No. :

1. What is the output of this C code?

void main()

char *str = "";

do

printf("hello");

} while (str);

a. Nothing b. Run time error

c. Varies d. Hello is printed infinite times

2. Consider an implementation of unsorted singly linked list. Suppose it has its representation
with a head and tail pointer. Given the representation, which of the following operation can be
implemented in O(1) time?
i) Insertion at the front of the linked list
ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list

a) I and II
b) I and III
c) I,II and III
d) I,II and IV

3. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

a) AB+ CD*E - FG /**


b) AB + CD* E - F **G /
c) AB + CD* E - *F *G /
d) AB + CDE * - * F *G /

4. What happens when we try to compile the class definition in following code snippet?

class Birds {};

class Peacock : protected Birds {};

a) It will not compile because class body of Birds is not defined.

b) It will not compile because class body of Peacock is not defined.

c) It will not compile because a class cannot be protectedly inherited from other class.

d) It will compile succesfully.

5. If integer needs two bytes of storage, then maximum value of an unsigned integer is

a) 216 1 b) 215 1

c) 216 d) 215 e) None of these

6. Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?

a) rem = (5.5 % 1.3) b) rem = modf(5.5, 1.3)

c) rem = fmod(5.5, 1.3) d) Error: we can't divide

7. Assuming, integer is 2 byte, What will be the output of the program?

#include<stdio.h>
int main()

{
printf("%x\n", -1>>1);
return 0;
}

a) Ffff b) 0fff
c) 0000 d) fff0

8. What will be the output of the program ?

#include<stdio.h>

int main()
{
static int a[2][2] = {1, 2, 3, 4};
int i, j;
static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
for(i=0; i<2; i++)
{
for(j=0; j<2; j++)
{
printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i),
*(*(i+p)+j), *(*(p+j)+i));
}
}
return 0;
}

a) 1, 1, 1, 1
2, 3, 2, 3
3, 2, 3, 2
4, 4, 4, 4
b) 1, 2, 1, 2
2, 3, 2, 3
3, 4, 3, 4
4, 2, 4, 2
c) 1, 1, 1, 1
2, 2, 2, 2
2, 2, 2, 2
3, 3, 3, 3
d) 1, 2, 3, 4
2, 3, 4, 1
3, 4, 1, 2
4, 1, 2, 3

9. The worst case complexity of binary search matches with

a) interpolation search b) linear search

c) merge sort d) none of the above


10. What is the output of the following program?

#include<stdio.h>
main()
{ int i = 1;
while( i++<=5 )
printf("%d ",i++);
}

a) 1 3 5 b) 2 4

c) 2 4 6 d) 2

11. int x=~1; What is the value of 'x'?

a) 1 b) -1

c) 2 d) -2

12. What is the output of the following program?

#include<stdio.h>
main()
{
struct student
{
int num = 10;
}var;
printf("%d", var.num);
}

a)10 b) garbage

c) runtime error d) Compile error

13. Which scanf() statement will you use to scan a float value (a) and double value (b)?
Float a;

Double b;

a) scanf("%f %f", &a, &b); b) scanf("%lf % lf ", &a, &b);

c) scanf("%Lf %Lf", &a, &b); d) scanf("%f %lf", &a, &b);

14. Is initialization mandatory for local static variables?

a) YES b) NO

c) Depends on the compiler d) Depends on the standard

15.Which of the following function can be used to terminate the main function from another
function safely?

a) return(expr); b) exit(expr);

c) abort(); d) Both b and c

16. How many times the program will print "CodeWhack" ?

#include<stdio.h>
int main()
{
printf("Code");
main();
return 0;
}

a) Infinite times b) 32767 times

c.) 65535 times d)Till stack overflows

17. What is the output of this C code?

int main()
{
int var = 010;
printf("%d", var);
}

a) 2 b) 8

c) 9 d) 10
18. Choose the right option

String *x,y;

a) x is a pointer to a string,y is a string

b) y is a pointer to a string,x is a string

c) Both x and y are pointer to string types

d) none of the above

19. Which of the following is illegal?

a) int *ip;

b) string s,*sp=0;

c) int i,double *dp=&i;

d) int *pi=0;

20.Which of the following is not a jump statement in C++?

a) break

b) Goto

c) Exit

d) Switch

S-ar putea să vă placă și