Placement Papers: CDAC Paper 2006 Part 3

Examrace Placement Series prepares you for the toughest placement exams to top companies.

  1. What is time required to insert an element in a stack with linked implementation?

    1. (1)

    2. (log2n) <____ans

    3. (n)

    4. (n log2n)

  2. Which of the following is the feature of stack? All operations are at one end It cannot reuse its memory All elements are of different data types Any element can be accessed from it directly<____ans

  3. Time taken for addition of element in queue is

    1. (1)

    2. (n)

    3. (log n) <____ans

    4. None of these options

  4. When is linear queue said to be empty? Front = = rear Front = rear-1 Front = rear + 1 Front = rear<____ans

  5. When queues are created Are initially empty<____ans Are initialized to zero Are considered full None of the above

  6. What would be the output of the following program? #include main () { printf ( “\n%c” “abcdefgh” [4]); } abcdefgh d e____ans error

  7. Select the correct C code which will read a line of characters (terminated by a \n) from input_file into a character array called buffer. NULL terminate the buffer upon reading a \n. Int ch, loop = 0; ch = fgetc (input_file); while ( (ch! = ‘\n’ ) && (ch! = EOF) ) { buffer[loop] = ch; loop + +; ch = fgetc (input_file); } buffer[loop] = NULL; int ch, loop = 0; ch = fgetc (input_file); while ( (ch = “\n” ) && (ch = EOF) ) { buffer[loop] = ch; loop--; ch = fgetc (input_file); } buffer[loop] = NULL; int ch, loop = 0; ch = fgetc (input_file); while ( (ch <> “\n” ) && (ch! = EOF) ) { buffer[loop] = ch; loop + +; ch = fgetc (input_file); } buffer[loop] = -1; None of the above

  8. What is the output of the following code? void main () { int a = 0; int b = 0; + + a = = 0 | + + b = = 11; printf ( “\n%d, %d” a, b); } 0, 1 1, 1 <____ans 0, 0 1, 0

  9. What is the output of the following program? #define str (x) #x #define Xstr (x) str (x) #define oper multiply void main () { char * opername = Xstr (oper); printf ( “%s” opername); } opername Xstr multiply <____ans Xstr

  10. What is the output of the following code? #include #include void main () { char * a = “C-DAC\0\0ACTS\0\n” printf ( “%s\n” a); } C-DAC ACTS ACTS C-DAC <____ans None of these

  11. #include void main () { while (1) { if (printf ( “%d” printf ( “%d” ) ) ) break; else continue; } } The output is Compile time error Goes into an infinite loop Garbage values <____ans None of these options

  12. Select the correct C statements which tests to see if input_file has opened the data file successfully. If not, print an error message and exit the program. If (input_file = = NULL) { printf ( “Unable to open file. \n” ); exit (1); } if (input_file! = NULL) { printf ( “Unable to open file. \n” ); exit (1); } while (input_file = NULL) { printf ( “Unable to open file. \n” ); exit (1); } None of these options

  13. The code int i = 7; printf ( “%d\n” i + + * i + + ); prints 49 prints 56 <____ans is compiler dependent _expression i + + * i + + is undefined

  14. Recursive procedure are implemented by Linear list Queue Tree Stack<____ans

  15. Which of these are reasons for using pointers?

    1. To manipulate parts of an array

    2. To refer to keywords such as for and if

    3. To return more than one value from a function

    4. To refer to particular programs more conveniently

    Which is correct?

    1. 1 & 3<____ans

    2. only 1

    3. only 3

    4. None of these options

  16. The _expression x = 4 + 2 %-8 evaluates to-6 6 4 None of these options

  17. What is the output of the following code? #include main () register int a = 2; printf ( “\nAddress of a = %d,” &a); printf ( “\tValue of a = %d” a); Address of a, 2 <____ans Linker error Compile time error None of these options

  18. What is the output of the following code? #include void main () { int arr[] = { 0, 1, 2, 3, 4, 5, 6}; int i, * ptr; for (ptr = arr + 4, i = 0; i ⇐ 4; i + + ) printf ( “\n%d” ptr[-i]) (as the 0 = 4, for-1 it becomes = 3); } Error 6 5 4 3 2 0 garbage garbage garbage garbage 4 3 2 1 0 <____ans

  19. Which of the following is the correct way of declaring a float pointer: Float ptr; float * ptr; <____ans * float ptr; None of the above

  20. If the following program (newprog) is run from the command line as: Newprog 1 2 3 What would be the output of the following?

void main (int argc, char * argv[]) { int I, j = 0; for I = 0; I j = j + atoi (argv[I]); printf ( “%d” j); }

123

6

123

Compilation error<____ans

Sign In