CMC Ltd. Campus Placement Paper - II : Technical Aptitude

2 comments
CMC Ltd Technical Placement Paper-2:

1) Which of the following is true?
A O(1) < O(n) < O(log n) < O(n log n) < O(n2 )
B O(1) < O(log n) < O(n) < O(n2) < O(n log n)
C O(1) < O(n) < O(n log n) < O(log n) < O(n2 )
D O(1) < O(log n) < O(n log n) < O(n2)

2) The ideal data structure to handle backtracking is?
A Queue
B Tree
C Stack
D Linked list

 3) Which of the following sorting algorithms does not have worst case running time of O(n2) ?
A Merge Sort
B Quick Sort
C Bubble Sort
D Insertion Sort

4) The following operations are performed on a stack:
push(10), push(20), pop, push(10), push(20), pop, pop, pop, push(20), pop. The sequence of values popped out is

A) 20, 10, 20, 10, 20
B) 20, 20, 10, 10, 20
C) 10, 20, 20, 10, 20
D) 20, 20, 10, 20, 10

5) In a memory system, read access takes 100 ns and write access takes 80 ns. If 60% of the access requests are reads, what is the average access time of the memory?
A) 3 ns
B) 92 ns
C) 108 ns
D) 88 ns

6) Which one of the following is the most suitable data structure for applications involving frequent additions and deletions of data elements?
A Stack
B Arrays
C Linear lists
D Linked list

7) Consider the C language code given below.
int *a;
int b[2];
a = b;
b[0] = -46;
b[1] = -23;
*a = -34;
(*++a)++;
What are the values of b[0], b[1] at the end.
A -34, -24
B -46, -22
C -34, -22
D -46, -23

8) Which of the following shell variable is used to return the process ID of the current shell?
A) $!
B) $$
C) $*
D) None

9) The system call that is key to multitasking in UNIX
A) Exec
B) Fork
C) System
D) None

10) When a binary tree is traversed in preorder and inorder, the labels of the nodes are printed as below.
Preorder: A B C D E F G H
In order: B C A E G F D H
In what order the nodes appear if the same binary is traversed in post-order?
A) C B G F E H D A
B) C B E G F H D A
C) C B F G E D H A
D) Can’t be decided unless tree representation is given

11) if c1 then statement1
else if c2 then statement2
else {
statement3;
if c3 then statement4;
statement5;
}
C1, c2, c3 are conditional tests yielding Boolean values:
c1 will be true with 40% of probability
c2 will be true with 50% of probability
c3 will be true with 10% of probability
The probability that statement4 will be executed is
A) 60%
B) 30%
C) 10%
D) 3%

12) The following conditions are necessary for a deadlock
I) Mutual exclusion
II) Hold & wait
III) No preemption
IV) Circular waits
A) I, II, III only
B) II, III, IV only
C) I, II, IV only
D) All of the above

13) i=0; sum=0; j=0;
while (i<=50)
{
i = i + (j ? 2 : 3);
j = !j;
sum += i;
}
printf ("%d", sum);
What is the output?
A) 410
B) 630
C) 490
D) 530

14) If x then y else false
The above statement is equal to following Boolean expression
A) x OR y
B) x AND y
C) x XOR y
D) NOT x

15) Octal equivalent of hexadecimal number AB is:
A 523
B 253
C 171
D 1010 1011

16) Instruction sequencing is done by the following register:
A) Stack pointer
B) Instruction register
C) program counter
D) Accumulator

17) Find the odd one out
A) Semiconductor memory
B) magnetic memory
C) Charge coupled memory
D) Virtual memory

18) Which of the following is a valid flip-flop?
A) JK Flip-flop
B) S Flip-flop
C) R Flip-flop
D) None

19) Which of the following allows multiple program threads to share the same resource?
A) Mutex
B) Pipe
C) File Handle
D) Deadlock

20) Postfix representation of A / (B + C) * (D - E)

A) /A*+BC-DE
B) ABC+DE-*/
C) ABCDE-+*/
D) A+BC-DE*/

21) Range of signed integers represented by 8 bits:
A) 127 to 127
B) 128 to 127
C) 127 to 128
D) 128 to 128

22) 2's Complement of 1010001010110111
A) 0101110101001000
B) 0101110101001111
C) 0101110101000111
D) 0101110101000000

23) Which of the following is part of the CPU (Central Processing Unit)
A) Harddisk
B) Registers
C) RAM (Random Access Memory)
D) DMA (Dynamic Memory Access)

24) What is the 2 GB (Giga Bytes) equivalent value in decimal?
A) 2141592658
B) 2097152948
C) 2000000000
D) 2147483648

25) What is decimal and binary equivalent of an octal number 127?
A) 87 and 1010111
B) 78 and 1010110
C) 87 and 1010110
D) 78 and 1010111

26) What is the address space range of a microprocessor with 32-bit address bus?
A) 0x00000000-0xFFFFFFFF
B) 0x000000-0xFFFFFF
C) 0x0000000-0xFFFFFFF
D) 0x0000-0xFFFF

27) Which of the following statement is valid regarding recursive function?
A) May have a potential of stack overflow error
B) Cannot pass pointers as arguments to the recursive function.
C) The function is called in a 'for' or 'while' loop by the calling program.
D) Best to use in implementing quick sort

28) Left shift of bits in binary data is equivalent to?
A) Addition of 2
B) Division by 2
C) In some other binary number depending on the initial data
D) Multiplication by 2

29) !( A || (B && C) ) can also be represented as : ( Note : ! is negation )
A) !A || !B && !C
B) !A && !(B && C)
C) !A || !(B && C)
D) !A && ( !B || !C&& A)

30. RACE condition means:
A) two threads of a single program trying to update the same memory at the same point of time resulting in unpredictable data in the memory.
B) A condition where multiple processes are waiting for the CPU time.
C) A condition which results in deadlocks.
D) Two threads halted without further execution, each waiting for the lock obtained by the other thread to be released.

31) What is REENTRANT code segment?
A) Code that can be part of a for or while loop.
B) Code that is part of a recursive function.
C) Code that guarantees safe and defined behavior even when parallelly executed by two threads.
D) Code that may result in a race condition.

32) Decimal equivalent of octal number 888 is:
A) 8 + 8*8 + 8*8*8
B) (8*8*8*8) - 1
C) 888
D) None of the above

33) What is the lowest and highest number that can be represented by a N-digit number in Octal number system
A) Zero and (N raised to the power of 8)
B) Zero and (8 raised to the power of N)
C) Zero and ((8 raised to the power of N) minus 1)
D) Zero and ((N raised to the power of 8) minus 1)

34) For “C” language, what is the best reference manual?
A) “C” language from Microsoft
B) “C” language by Balaguru swamy
C) “C” language by Kernighan & Ritche
D) None of the above

35. RDBMS is related to:
A) Theory of Relativity
B) Relational Data structures with Business Management System
C) Relational Algebra
D) All of the above

36) Choose a set that has an odd element:
A) Windows, Linux, DOS
B) Oracle, SQL Server, Visual Studio
C) Mouse, Keyboard, Touch screen
D) All of the above

37) There are two tables in a database namely EMPLOYEE and DEPARTMENT. EMPLOYEE table has 6 columns, 60000 rows and DEPARTMENT table has 4 columns, 40000 rows. What is the output of the following SQL query?
Select count (*) from EMPLOYEE, DEPARTMENT
A) 24
B) 10
C) 100000
D) 2400000000

38) Input and outputs of a compiler:
A) Object file, Symbol table
B) Source code, Object File
C) Object File, Windows Application
D) None of these

39) Given 110112 which of the following is false?
A) In unsigned notation it is 27 base 10
B) In 1's complement notation it is -4 base 10
C) In 2's complement notation it is -5 base 10
D) In signed magnitude notation it is +11 base 10

40) How many 1's are present in the binary representation of (769.625)10?
A) 9
B) 4
C) 5
D) 6

41) Choose the right declarations for the main() in C
A) int main(int argc, char *argv[]);
B) void main(int argc, char *argv[]);
C) int main(void);
D) All the above

42) Choose the valid typedef definitions from the following C code snippets
A) typedef struct{...}T;
B) typedef struct S{...}T;
C) typedef {...}T;
D) typedef struct S{...};

43) What are the correct ways of accessing member x in the following structure
typedef struct{
int x;
char y;
}T;

T *t = malloc(sizeof(T));
T s;

A) t->x;
B) (*t).x;
C) s.x;
D) All the above.

44) Choose valid statement from the following to declare a variable to hold pointer to an array of functions with return type (char *) and takes an argument int
A) char * (**p) (int x);
B) char * (*p[]) (int x);
C) char * (p[]) (int x);
D) char * (*(*p)) int x;

45) What is the value of the variable z in the following C code snippet at the end of the program
void test(void){
int x=3;
int y=5;
int z;

x += x++;
z = 2 * ++x + y;
}
A) 19
B) 21
C) 15
D) 17

46. What is the result of the variable z in the following C code snippet at the end of the program?
#define modify(A, B) ((A) < (B) ? (++A) : (B--))
int a=4,b=2;
int x = modify(a,b);
a=3;b=6;
int y = modify(a,b);
int z = y - x;
A) 1
B) 2
C) 3
D) None of the above

47) Which of the following doesn't represent a storage class
A) auto
B) public
C) register
D) static

48) Which of the following are not valid C language statements
A) for(;;){}
B) while(true){}
C) while(1){}
D) None of the above

49) Which of the following are not valid function for memory allocation in standard C library
A) malloc()
B) realloc()
C) memalloc()
D) calloc()

50) Which of the following are not valid C language keywords
A) extern
B) function
C) const
D) register

51) What is the value of the variable e in the following C code snippet
int a=3,b=4,c=2,d=3;
int e = (a << 1) * b / c - (d >> 1);
A) 8
B) 10
C) 13
D) None of the above

52) Consider the C language code given below.
int *a;
int b[2];
a = b;
b[0] = -46;
b[1] = -23;
*a = -34;
(*++a)++;
What are the values of b[0], b[1] at the end.
A) -34, -24
B) -46, -22
C) -34, -22
D) -46, -23

53) i=0; sum=0; j=0;
while (i<=50)
{
i = i + (j ? 2 : 3);
j = !j;
sum += i;
}
printf ("%d", sum);

What is the output?
A) 410
B) 630
C) 490
D) 530

54) Assuming all required headers are included, see the below code segment and select the correct option(s) A,B,C and/or D given below and write your comments, if any, on the code segment:
Line 1 : int *iptr ;
Line 2 : printf("Type a number:");
Line 3 : scanf("%d", iptr);
Line 4 : printf("Integer value is %d\n", iptr);

A) Missing '&' before 'iptr' in Line 3.
B) Program will cause segmentation fault.
C) Program will not compile as there are errors in this code segment.
D) Program prints the given number in Line 4.

55) int a = 1; b = 2; c = 3;
if( ( a == 1 ) && ( ++b == 2 ) && ( c-- == 1 ) )
{
printf( "%d,%d,%d\n", a,b,c );
What is the output ?

A) 1,2,3
B) 1,3,2
C) 2,3,4
D) 1,3,3

56) Assuming all headers required are included. see the program below and answer
and answer
void my_int_alloc( int *i_ptr, int sz ); /* function to allocate memory */
int main()
{
int *int_ptr ;
my_int_alloc(int_ptr,20);
int_ptr[19] = 100;
printf("%d",int_ptr[19]);
free(int_ptr);
return 0;
}

void my_int_alloc( int *i_ptr, int sz )
{
i_ptr = (int *)malloc(sz*sizeof(int)); /* assume malloc never fails */
return;
}
Select the correct option(s) from A, B, C and/or D below:

A) The program has memory leaks and it tries to free unallocated memory.
B) The printf prints the value '100'.
C) There should not be a ‘return’ statement in a function returning void
D) The program will not compile.

57) Assuming all headers are included, see the below program segment and select
and select
the option A, B, C and/or D
char src[11] = "CMC";
char dest[11] = "LIMITED";
strcpy(src+3,dest);
printf("%s\n",src);

A) Program has compilation errors in the line having strcpy call.
B) Program results in segmentation fault.
C) Program prints "LIMITED"
D) Program prints "CMCLIMITED"

58) The program
int main(int argc , char *argv[])
{
printf("%s\n", ++(*(argv+argc-2)));
return 0;
}
if run with the command
$> prog_name one two three four
will have the below behaviour ( select the right option )

A) program has compilation errors
B) Program prints "three"
C) program prints "hree"
D) program prints "three four"

59) Which of the following statements are valid regarding "static" variables in C?

A) Have global scope and lifetime till the end of the program.
B) Have block scope and lifetime till the end of the block.
C) Have block scope and lifetime till the end of the program.
D) Have global scope and lifetime till the end of the block

60) What is the output of the code segment below?
char c;
int i = 0 ;
for( c = 'A' + i ; c < 'Z' ; c += 2,i++ )
{
printf("%c", c);
}
A) ADHMS (skips 2,3,4,5 characters in between A and Z)
B) ACEGIKMOQSUWY (skips one char in between A and Z)
C) ABCDEFGHI...Y (prints all characters from A to Y)
D) Program does not compile.

61) Select the correct statements in relation to the "realloc" function
A) The realloc tries to allocate new memory which starts at the old memory and if it cannot find sequential memory extending the old memory, realloc will fail...
B) After the call to realloc, we need to copy the data from the old pointer
C) Based on where the new memory is allocated, the realloc function takes care
Of copying the data into the new location, but the caller needs to free the
D) Both data copy and freeing of old memory whenever required, is taken care

62) In the declaration char c_arr[100] = "CMCLIMITED" ; , c_arr is :
A) a constant pointer to character.
B) non-const pointer to a character constant.
C) non-const pointer to character.
D) a constant pointer to constant character.

63) Looking at the code lines below, select the correct statement(s) below:
Line 1 char *c_ptr;
Line 2 char a_arr[100];
Line 3 c_ptr = (char *) malloc (10*sizeof (int));
Line 4 c_ptr = c_arr;
Line 5 free (c_ptr);
A) Line 3 has compilation error: it uses sizeof (int) instead of sizeof (char)
B) Line 4 has an error as we cannot assign an array pointer to a normal pointer.
C) Line 5 has a compilation error.
D) Line 5 has undefined behavior.

64) Which of the following functions deal with binary output into a file?

A) fprintf()
B) fputs();
C) fwrite();
D) All of the above.

65) Which of the following are valid file operation functions in C?
A) fseek()
B) ftell()
C) rewind()
D) All of the above.

66) Assuming all headers included, indicate the behavior of the below program:
Int arr[10] = {1,2,3,4,5,6,7,8,9,10};
Int I = 0;
while( I < 10 )
{
printf(“%d\n”, *(arr++));
}

A) prints numbers from 1 to 10
B) prints numbers from 1 to 9
C) prints ‘1’ ten times.
D) program has compilation errors.

67) Given a structure typedef struct { char x; int y, int z} mystruct;
sizeof(mystruct) will return
A) 5 -- Always
B) 6 -- Some times
C) 8 -- Based on Memory size
D) None of the above

68) char *p = (char*) malloc(2000000*2/10+4);
int length = strlen(p);
Output of the above program:
A) 400004
B) 200002
C) NULL
D) None of the above

69) A program is written in “C” language , and an executable is made by compiling it on unix/linux environment. Can we run the executable on windows operating system.
A) Yes, Always
B) Only on vista operating system
C) Never
D) If we change extension to .exe, it will run

70) Main difference of a struct in C and C++
A) In C members are private, c++ members are virtual
B) In C members are public, c++ members are private
C) In C members are virtual, c++ members are private
D) None of the above

2 comments:

  1. i need the answers for the above question
    how can i get it

    ReplyDelete
  2. need urgent plz mail it to me

    ReplyDelete