You are on page 1of 28

Aug 19 FRP C AND DataStructure QUESTIONS It is also useful for pre-assesment @Joining Day 1. printf("%d %d %d",sizeof(25.

75),sizeof(123),sizeof(‘p’)) a. 2 2 2 b. 4 2 2 c. 8 4 1 d. 8 2 2 2. int i=5; fun( ) { printf("%d\n", i * 3); } main( ) { int i= 2; { int i = 3; printf(" %d", i); fun(); } } 1. 3, 15 2. 3, 6 3. 3 4. 0 3. #define xsq(x) x*x main( ) { int i, j;

i = 5; j = xsq(i-2); printf(“%d\n”, j); } 1. –7 2. 9 3. 13 4. 29 4. main( ) { int a=35; printf(“ %d %d %d\n”, a == 35,a=50,a>40); } 1. 1 50 1 2. 1 50 0 3. 0 50 0 4. 0 50 1 5. void main() { char a[]="123abcd"; clrscr(); printf("%d",strlen(a)); getch(); } 1. 6 2. 7 3. 8 4. 5

One b. break. default: printf(“Default”). break. switch(i) { case 1: printf("One").6. Two c. } } a.var). default: printf("Error"). void main() { switch('a') { case 'A': printf("Zero"). main() { static int var=5. main(). break. if(var--) { printf("%d". 4 3 2 1 0 b. case 97: printf("One"). .j=2. 5 4 3 2 1 d. void main() { int i=1. case j: printf("Two"). Default d. Compiler Error 8. break. } } a. 4 3 2 1 c. break. break. 5 4 3 2 1 0 7.

110 d. Error 10.sum). } int changevalue(int x) { return(x+=1). clrscr(). } a. int x. int modifyvalue() { return(x+=10). } printf("\nsum=%d". Error d. One c. 120 b. } void main() { . Compiler Error 9. sum+=p++. while(p<20) { p++.sum=0. Zero b.} } a. void main() { int p=1. 100 c.

12 13 d. 11 12 c. return i>0?main():0.ptr). printf("%s". 2 1 0 d. changevalue(x). 3 2 1 c. Hello World ello World .ptr). 13 13 11. x++. printf("\nSecond output : %d". Iello World Iello World b. printf("First output : %d". ptr++. printf("%s".x). modifyvalue(). 12 12 b. printf("%d". 2 1 12.x). changevalue(x). void main() { char *ptr="Hello World". *ptr++.i--). } a. main() { static i=3. 3 2 1 0 b. } a. } a. x++.int x=10.

int const *p. 6 c."hewlet-packard". 2 5 3 d. 5 5 3 b. what will be the output of the following statement.c. 2 1 c. char str2[]="abcd". char **p. ello World llo World 13.sizeof(str2). 2 2 d. a. ello World ello World d."ibm"}. a. P is a character pointer variable then. } a. printf("%d %d %d". 5 b. Garbage Value 14.sizeof(*p)). *p=5. 4 5 3 c. Compiler Error d.sizeof(p). 1 2 b. void main() { char *s[]={"dharma". p=s."siemens".*p++). 1 1 16. 1 5 3 15. . printf("%d %d".sizeof(str1).sizeof("ab")). void main() { char *str1="abcd". printf("%d".

harma harma ewlet-packard b. harma hewlet-packard siemens d. i=64/square(4).printf("%s". (*ptr)++. harma harma hewlet-packard 17.ptr). printf("\n%s". printf("\n%s". } a. } a.ptr). #define square(x) x*x void main() { int i=7. ptr++. clrscr().++*p). printf("%s\n". dharma harma ewlet-packard c. Samco Systems Samco Systems b. void main() { char *ptr="Ramco Systems". . amco Systems mco Systems 18.++*p). amco Systems amco Systems d. printf("%s".*p++). Samco Systems amco Systems c.

int pl:2. printf("%d %u". } a.a.a. a.j.no). } a. }.a. a.a.a. int x:3.no=0.pl=1.x). struct one { int no:1. 17 17 11 2 c. 7 b. 4 19. void main() { struct one a. printf("\n%d %u". printf(" %d %d %d".no.pl.j=10. 16 17 11 2 b. printf("\n%d %u". 64 d.a.i). a.x)):(y) void main() { int i=15.printf("%d". 16 c. .x.i.k).k=0. k=man(i++.x=3. 16 16 11 2 d.y) (x)>(y)?(printf("%d". 16 17 12 2 20. #define man(x.pl).++j).

struct emp emp1. }e1. } a. struct emp emp1.e1)). 4 4 d. 1 1 22 22 21. printf("%d %d". 0 0 11 33 b.} a. 0 0 22 33 c. }. void main() { struct emp { struct e { int *a. int a. 4 2 22. 1 1 22 33 d.sizeof(emp1). 2 2 c. struct emp { .sizeof(emp1. 2 4 b.

main() { printf("Enter 1 values:"). a) free(temp) b) temp->prev->next = temp->next c) temp->next->prev = temp->prev. Compiler Error 23. temp ->next -> prev = temp -> prev. scanf("%d%d". }.a. } a.int a. Arrange the code in order to delete a node being pointer by temp.a.&emp1. if temp is pointing to a node other than first and last node temp -> prev ->next = temp ->next.emp1. 25 25 c.a). a) b c a b) c b a c) a b c d) both a and b 24. 10 10 d.a). What does below code do. a) no effect b) inserts a node c) deletes a node d) shuffling of pointers . 10 25 b.&emp1.emp1. //The given input is 10 and 25 printf("a=%d a=%d".

b=temp. void main() { int i=5.b) temp=a.a.25.i++.a. printf("a=%d b=%d".++i.i++.i++. which is the faster traversable dynamically growing list a) Binary Search Tree b) Singly Linked List c) Doubly Linked List d) Using Array 1.b=6. printf("%d %d %d %d %d". void main() { static int a=5.b).b. } (a)a=5 b=6 (b)a=6 b=5 (c)a=6 b=0 (d)None of these 3. a=b. printf("%d %d %d". c=(--a. b++)-c. #define swap(a. .c). } (a)0 3 -3 (b)Compile-Time Error (c)0 3 -1 (d)0 3 0 2.c=3.b=2.b).temp.++i). if (a > b) swap(a. void main() { int a=1. } (a)Compile-Time Error (b)10 9 8 7 6 (c)9 8 7 6 6 (d)10 8 7 6 6 4.

h> int main(int argc. case 6: printf(" 6 "). n =10. i+=2) printf("%d". } 1. } (a)84 (b)840 (c)852 (d)864 5. Hello Genesis 2. What is the output of the program? #include <stdio. return 0. default: printf(" 10 "). for (i=1.void main() { int i. 5 10 6 . } } 1. i<n--. printf("Hello Genesis")). 5 2.h> main() { switch (5) { case 5: printf(" 5 "). char *argv[]) { printf(" %d". None of the above 6. #include <stdio. Hello Genesis 13 4. 13 Hello Genesis 3. n-i).

between 2 strings 4. 5 6 7. It disables the memory address with the pointer 10. union 3. 5 10 4. integer 2. It places the memory address with the pointer in free store 4. Static 9. Which of the following is not a storage class in C? 1. It erases the contents of any type and cleans the pointer 3. Which argument of function 'strncmp()' specifies number of characters to be compared? 1. What is the significance of the free() function? 1. third 8. second 3. Register 3. pointer . Extern 4. It assigns the pointer a NULL value 2. Stack 2. first 2.3. What is the data type of FILE? 1.

strlen 14. Stack 2.4. Queue 3. alloc . printf 2. Which of the following function does not support dynamic memory allocation? 1. 11 3. 25 2. #include <stdio. Tree 13. Which of the following is a non-linear data structure? 1. strcpy 4. Which of the following function does not return an integer value? 1. structure 11. Linked List 4. } 1. 10 4. scanf 3. sq(3 + 2)). Compilation error 12.h> #define sq(a) a * a void main() { printf("%d".

103 2 16. realloc 3. &p)). Queue is _________________ a) LIFO b) LILO c) FIFO d) Both b & c 18. 103 3. printf(" %d ". In 'switch' statement 3. 1. Where do we use a 'continue' statement? 1. In 'goto' labels 4. malloc 4. None of the above 17. What is the output of the program if the input is 103? main() { int p = 234. 103 3 4.2. In 'if' statement 2. printf("%d". scanf("%d". What is the postfix expression for A + B * C / D – E * F / G . } 1. p). 3 103 2. free 15.

(d) printf("%d". Write one statement equivalent to the following two statements: x=sqr(a).sqr(a)). return(x). union U { . (b) printf("sqr(a)"). int i=5.a) ABC*D/+EFG*/b) ABC*D/+EF*G/c) ABCD/*+EF*G/d) None of these. } a) error b) 5 c) 2 d) 0 21. 20. (c) return(a*a). printf("%d". Choose from one of the alternatives (a) return(sqr(a)). 19.abc(i=i/4)). } main() { int i=4. int abc(int z) { return i/2.

union U ob. a) 4 b) 2 c) 8 d) 7 22. what is the size of ob in bytes.int x. front . 16. 9.B * C / D + E * F / G 24. float y. rear 23. 26. delete d.add . 11.push . 14. What is the Infix expression for . 88.append . char s[2]. 69 a) 69 b) 25 c) 26 . The operation for adding and deleting an entry to a stack is traditionally called: a.+ A / * B C D / * E F G a) A + B * C / D – E / F * G b) A + B / C * D – E * F / G c) A + B * C / D – E * F / G d) A . 36. pop e. 72. What would be the root node if we enter the following data set (in the respective order) into a standard program to construct a Binary search tree? 25. 21. delete b.insert . delete c. 45. }.

--val. return(0). temp -> next -> prev = temp -> prev.val. . printf("%d %d %d %d". } temp -> prev -> next = temp -> next. free(temp). } (a)3 4 6 5 (b)5 5 6 5 (c)4 4 5 5 (d)None of these 2.d) 9 25. a) no effect b) deletes some node c) deletes 2nd last node d) deletes last node 1. 10 be the number of nodes temp = head. what does the code below do. What will be the output of the following program : int main() { int val=5.val--).++val. where head is pointing to first node & temp is a temporary pointer. while (temp->next->next!=NULL) { temp = temp ->next.

} a)Success b)TestSuccess c)Compile-Time Error(d)Failure 5. return(0). return(0).y=3. printf("%d". if ((printf("%s". } (a)40 (b)30 (c)Compile-Time Error (d)None of these 3.#define Compute(x.(-x+y)) * Compute(z. What will be the output of the following program: int main() { int val=5.y. else printf("Failure").x. return(0). What will be the output of the following program : int main() { char str[]="Test". printf("%d".Compute(y.z=4.z.z) (x+y-z) int main() { int x=2. } (a)7 (b)C7 (c)Compile-Time Error(d)CSkills7 4. .str)) == 4) printf("Success"). What will be the output of the following program : int main() { int val=5. val=printf("C") + printf("Skills").(-y+z))).val).

return(0). a)Inorder : D H B E A F C I G J Preorder: A B D H E C F G I J Postorder: H D E B F I J G C A b)Inorder : D H B E A F C I G J Preorder: D H E A B C F G I J Postorder: H D E B F I J G C A c)Inorder : D H B E A F C I G J Preorder: A B D H E C F G I J Postorder: H D E B F I J G A C . return(0).printf("%d". Traverse the given tree using Inorder. } (a)Data types not allowed (b)Compile-Time Error(c)3 (d)2 7.sizeof(int)). } (a)Compile-Time Error (b)Lvalue required Error (c)10 (d)11 6. Preorder and Postorder traversals. void main() { printf("%d".5+val++). In tree construction which is the suitable efficient data structure? (a) Array (b) Linked list (c) malloc (d) Queue 8.

printf("%d". 4 3 2 1 b.h> main() { struct xx { int x=3. main() { static int var = 5. use dot (. }. char name[]="hello". 4 3 2 1 0 c. if(var) main(). #include<stdio. } 1.h> main() { . #include<stdio.var--). 5 4 3 2 1 d. printf("%s". Compiler Error c. printf("%d ".s->x). 0 0 0 0 0 10.s->name). struct xx *s. Run time error d. 3 hello b.d)Inorder : H D B E A F C I G J Preorder: A B D H E C F G I J Postorder: H D E B F I J G C A 9. } 1.) operator 11.

10 20 c. 20 20 d. 10 10 14. } 1.y=20. printf("x= %d y = %d\n". 7 13. 6 d. printf("%d %f".x.++j).*a=*a-*b. 8 c.&y). 6 6. float j.y). i.*b=*a-*b. int swap(int *a. swap(&x. return(ret). 5 5.const int i=4. printf("\n %d".000000 b. } int ret(int ret) { ret += 2. 20 10 b. Compiler Error b. } main() { int x=10.int *b) { *a=*a+*b. void main() { int k=ret(sizeof(float)). main() { .5. } 1. } 1. compiler error 12.000000 d. j = ++i. 5 6.000000 c.++k).

0 1 2 c.char *p = “ayqm”. } 1.c). switch (i) { static int i. z 15. b c. char c. case 2: printf("2"). a b. y d. 2 0 16. c = ++*p++. i = 3. MESS junk 17. default : printf("0"). #define MESS junk main() { printf(“MESS”). switch(i) { case 1: printf("1"). Error c. main () { int i = 5. } 1. Junk b. main() { float i=1. MESS d. printf(“%c”. Compiler Error e.5. . i = i * i. 0 b. } } 1. 1 2 0 d.

*fp2. } fn(int i) { return ++i. main() { int i=10. fp1=fopen("one".fp2) . case 4: i = i + i.fp1) . fclose(fp1) . 10 10 c. } (a) 10 (b) 11 (c) 12 (d) Compilation error 19. fputc('B'. } printf (“%d”. 9 b. 18 18 e. main() { FILE *fp1.i). 0 5 d.case 3: i = i + i. What would be the output of the following program. Int fn(int).i)."w") . } 1. printf (“%d”. printf("%d". fputc('A'. 18 5 18. fn(i). . fp2=fopen("one". case 5: i = i + i."w").i).

The new content will append in existing file. If Any? 1. no error. no error. If suppose root to be deleted then which node will be the root node 1.--b. error. B . what type of Binary Tree is the following tree below 1. But It will create one more file. binary tree 2. But It will over writes on same file. 1. 2.b=*ptr. 1. 4. 20. strictly binary tree 3. 3.*ptr=&a. void main() { int a=555.*ptr++). printf("%d %d %d". complete binary tree 4.++a. } (a)Compile-Time Error (b)555 554 555 (c)556 554 555 (d)557 554 555 21. } Find the Error. not a binary tree 22.fclose(fp2) . It will not allow. no error.

Both a and b are correct 23. Any node 4. When fopen() fails to open a file it returns a) NULL b) –1 c) 1 d) None of the above 24. G 3. Which function is used to detect the end of file a) EOF b) feof( ) c) ferror( ) d) NULL 25. If the CPU fails to keep the variables in CPU registers. in that case the variables are assumed a) static b) external c) global d) auto ANSWERS : --1) d 822 --2) a 3 15 --3) a -7 --4) c 0 50 0 --5) b 7 --6) a .2.

43210 --7) d Compiler Error ---8) b One --9) c 110 --10) a 12 12 --11) b 321 --12) d ello World llo World --13) a Garbage Value --14) c 253 --15) b 21 --16) a harma harma ewlet-packard --17) b Samco Systems amco Systems --18) c 64 --19) .

a 16 17 11 2 --20) a 001133 --21) d 42 --22) b 25 25 --23) d both a and b --24) c deletes a node ---25) c Doubly Linked List .