Вы находитесь на странице: 1из 12

1.Which is not a proper prototype? A. int funct(char x, char y); B. double funct(char x) C. void funct(); D. char x(); 2.

what is the problem of using getchar()? We need to press enter key to further processing.. 3. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A. The element will be set to 0. B. The compiler would report an error. C. The program may crash if some important data gets overwritten. D. The array size would appropriately grow. Explanation: "In C there is no check to see if the subscript used for an arrayexceeds the size of the array. Data entered with a subscript exceeding the array size will simply be placed in memory outside the array; probably on top of other data, or on the program itself. This will lead to unpredictable results, to say the least, and there will be no error message to warn you that you are going beyond the array size. In some cases the computer may just hang. ". this is wat is written in kanetkar book. so i thnk it would be c... 4. scanf("%2d %2d",&val1,&val2); scanf("%3d %2d",&val1,&val2); scanf("%4d %3d",&val1,&val2); what will be the output for above ? If the Val1=1234 val2=567 1.) 12 34 2.) 123 4 3.) 1234 567

then if %3d %3d is given and val1=1234 and val2=567 then o/p vl b val1=123 nd val2=4(space) 5... 5. wat will be the output? printf ("%3d",1234); it gives output as 1234 the field width indicator in scanf function specifies MAXIMUM field width.... but the field width indicator in printf function specifies MINIMUM field width.....if the question would have been printf("%7d", 1234); then the output wd have been [3 spaces ]1234 bcz here the field width is 7(3 spaces + 4 integers)

6. Which of the following reads in a string named x with one hundred characters?(A) A fgets(x, 101, stdin); B. fgets(x, 100, stdin); C. readline(x, 100, '\n'); D. read(x); 7.Which is a good use for typecasting?(A) A. To allow division of two integers to return a decimal value. B. To allow your program to use nothing but integers. C. To change the return type of a function. D. To swap variables rapidly. 8. int a[3]={1,2,3} printf("%d,%d",*a+2,a[2]); o/p: 3,3 Header files contain (a) function prototypes (b) code (c) binary code (d) executable code Why do you need prototype declarations? (a) Any function should be declared before we use (b) For the programmers convenience (c) For linking the function (d) Needed for pre-processor D rite?

linked list are not suitable for DS of which one of the following problem? a)insertion sort b)binary search c)radix sort d)polynomial manipulation problem

organisation of files in hard disk is best represented usinga-queue b-dequeue c-linked list representation of tree d-stack

Binary search algorithm works best with a) sequential search trees b)arrays c)trees d)none

void *ptr; myStruct myArray[10]; ptr = myArray; Which of the following is the correct way to increment the variable "ptr"? 1)ptr = ptr + sizeof(myStruct); 2)++(int*)ptr; 3)ptr = ptr + sizeof(myArray); 4)increment(ptr);

every element in data set is examined in the order bpresented until the values being searched for is found in which technique??? a-binary search b-quick search c-linear search d-none

No of nested loop in bubble sort algorithm 1. 3 2. 4 3. 2 4. 1

Which of the following applications may use as a stack? a) syntax analyzer for a compiler b)keeping track of local variable at run time c)a parentheses balancing program d)all

int num[3]={1,2,3} here num=(num+1) results in--a- 1 b-2 c-3 d-compiler error Data structure stack can also be termed as a)FIFO b)LIFO c)LILO d)None

The time complexity of adding an element to a queue of n elements is a)O(n^2) b)O(n) c)O(1) d)none s[2][2] is same as a)s+4 b)*((s+2)*2) c)*(*(s+2)+1) d)*(*(s+2)+2)

The condition to be checked before the element is popped from the stack? a)stack overflow b)stack underflow c)no specific condition to be checked d)option 1& 2

arrays can be passed to functions by call by value call by value whr value is base address

call by reference both call by value and call by ref

in bubble sort the last element after the 1st iterataion is largest smallest 2nd largest none

Arrays can be passed as arguments to functions using call by value where value is base address of array call by value either by call by value or by call by reference none

char name[]={'s','a','t','y','m','\0'}; here array size is 5 or 6?????.will strings consider null pointer ?

s[2][2] is same as s+4 *((s+2)*2) *(*(s+2)+1) *(*(s+2)+2).

The non-leaf nodes of a binary tree with 2 or more nodes are also known as _____________ nodes a)outer

b)external c)root d)internal

Constant complexity implies maximum efficiency efficiency depends on input data minimum efficiency Efficiency is not dependent on input size

Which of the following is not true regarding recursion? a)recursive solution has less number of lines of code b)recursive solution require less memory c)recursive algorithm can always be written iteratively d)recursive solution is shorter & more elegant than iterative

what additional reqt. is placed on arrayso that binary search may be used to locate an entry? a) array elements must form a heap. b) array must have at least 2 entries. c)array size must b in power of 2 d)array must b sorted

Constant complexity implies a)maximum efficiency b)efficiency depends on input data c) maximum efficiency d)efficiency is not dependent on input size

Which of the following applications may use as a stack? a) syntax analyzer for a compiler b)keeping track of local variable at run time c)a parentheses balancing program all

int num[3]={1,2,3} num = num+1 result is 1 2 3 compiler error num = num+1 is a wrong statement ?? because we cannot initialize base adrres of array

A sorting method with _ _ _ _ _ _ _ _ is the most efficient method a. O(log n) b. O(n) c. O(1) d. O(n2)

The expression (*P).x is equivalent to 1) P.x 2).P->x 3)P->.x 4)P ->x

Suppose we have a circular array implementation of the queue class, with ten items in the queue stored at data[2] through data[11]. The CAPACITY is 42. Where does the push member function place the new entry in the array? data[11] data[12] data[2] data[1]

char a= a, b ='b' int i=1, j=2,x=1; Expression i==j? a-1 : b-1; J%3 ==0?i+4:x J%3?i+4:x a15

.Expression 1: i==j? a-1 :b-1....it means if i is equal to j, then a-1 will be executed else b-1 will be executed. So, here i is not equal to j......so b-1 will be executed. but b contains the character b, so here b-1 means ASCII(b) -1 which will give ascii value of a...SO ANSWER OF 1st EXPRESSION is a. Expression 2: J%3==0?i+4:x.....it means if J%3 is equal to 0, then i+4 will be executed else x will be executed.......So, here J%3 will give 2, so x will be executed......therefore, THE ANSWER OF 2nd EXPRESSION IS 1. Expression 3: J%3?i+4:x......if J%3 is true, then i+4 will be executed else x will be executed.......So, here J%3 is true because it is an arithmetic operation it will return some value...moreover it is not compared with any value or variable......so J%3 will return true and hence i+4 will be executed.....Therefore, THE ANSWER OF 3rd EXPRESSION IS 5. 16 June at 15:43 Like 3

scanf("%d%d",&val1,&val2) -----> 1234 567 scanf("%2d%2d",&val1,&val2)----> 12 34 scanf("%3d%2d",&val1,&val2)----> 123 4 scanf("%4d%3d",&val1,&val2)----> 1234 567

The first element of a 0 based array can be accessed by (a) array[n-1] (b) array[n] (c) array[1] (d) array[0] Which of the following list is suitable to insert an element without shifting of elements ? (a) Linked list (b) An array if extra space is left empty (c) Options 1 and 2 (d) none Average time complexity of sequential search??-----------o(n)

Which of the following sentences are correct about a for loop in a C program? 1: for loop works faster than a while loop. 2: All things that can be done using a for loop can also be done using a while loop. 3: for(;;); implements an infinite loop. 4: for loop can be used if we want statements in a loop get executed at least once. A.1 B. 1,2 C. 2,3 D. 2,3,4 #include <stdio.h> int main() { int ints[] = { 0, 1, 2, 3 }; int* i1 = ints + 1; int a = ++*i1; int b = a + *i1; printf("%d\n", b); return 0; } 4

#include <stdio.h> int main() { int ints[] = { 0, 5, 10, 15 }; int* i2 = ints + 2; int a = *i2++; printf("%d#%d\n", a, *i2); return 0; } 10 15

Which of the following is not a value type? 1.String 2.byte 3.int 4.float

Bubble sort is more suitable in which case: a)When most elements are arranged n few are to b arranged b)When all the elements are in reverse order c)When all the elements are in any order d)stack overflow Q81 Which is a good use for typecasting? A. To allow division of two integers to return a decimal value. B. To allow your program to use nothing but integers. C. To change the return type of a function. D. To swap variables rapidly. if any no. starts with 0(zero) then the compiler assumes that: a) hexadecimal b) octal c)decimal d)binary

main() { int i=5,j=10; printf("%d",i+++j); } a)15 b)16 c)17 d)error Whats o/p? Error?

1. Which of the following is the proper declaration of a pointer? A. int x; B. int &x; C. ptr x; D. int *x; 2. Which of the following gives the memory address of integer variable a? A. *a; B. a; C. &a; D. address(a); 3. Which of the following gives the memory address of a variable pointed to by pointer a? A. a; B. *a; C. &a; D. address(a); 4. Which of the following gives the value stored at the address pointed to by pointer a? A. a; B. val(a); C. *a; D. &a; 5. Which of the following is the proper keyword to allocate memory in C? A. new B. malloc C. create D. value 6. Which of the following is the proper keyword to deallocate memory? A. free B. delete C. clear D. remove

Вам также может понравиться