Vous êtes sur la page 1sur 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

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

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

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

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

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

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

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

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

25. which is the faster traversable dynamically growing list a) Binary Search Tree b) Singly Linked List c) Doubly Linked List d) Using Array

1. void main() { int a=1,b=2,c=3; c=(--a, b++)-c; printf("%d %d %d",a,b,c); } (a)0 3 -3 (b)Compile-Time Error (c)0 3 -1 (d)0 3 0 2. #define swap(a,b) temp=a; a=b; b=temp; void main() { static int a=5,b=6,temp; if (a > b) swap(a,b); printf("a=%d b=%d",a,b); } (a)a=5 b=6 (b)a=6 b=5 (c)a=6 b=0 (d)None of these 3. void main() { int i=5; printf("%d %d %d %d %d",++i,i++,i++,i++,++i); } (a)Compile-Time Error (b)10 9 8 7 6 (c)9 8 7 6 6 (d)10 8 7 6 6 4.

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

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

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

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

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

int x; float y; char s[2]; }; union U ob; what is the size of ob in bytes, a) 4 b) 2 c) 8 d) 7 22. The operation for adding and deleting an entry to a stack is traditionally called: a.add , delete b.append , delete c.insert , delete d.push , pop e. front , rear 23. What is the Infix expression for - + 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 - B * C / D + E * F / G 24. 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, 72, 16, 11, 88, 26, 9, 36, 21, 45, 14, 69 a) 69 b) 25 c) 26

d) 9 25. what does the code below do, where head is pointing to first node & temp is a temporary pointer. 10 be the number of nodes temp = head; while (temp->next->next!=NULL) { temp = temp ->next; } temp -> prev -> next = temp -> next; temp -> next -> prev = temp -> prev; free(temp); a) no effect b) deletes some node c) deletes 2nd last node d) deletes last node

1. What will be the output of the following program : int main() { int val=5; printf("%d %d %d %d",val,--val,++val,val--); return(0); } (a)3 4 6 5 (b)5 5 6 5 (c)4 4 5 5 (d)None of these 2.

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

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

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

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. main() { static int var = 5; printf("%d ",var--); if(var) main(); } 1. 4 3 2 1 b. 4 3 2 1 0 c. 5 4 3 2 1 d. 0 0 0 0 0

10. #include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); } 1. 3 hello b. Compiler Error c. Run time error d. use dot (.) operator 11. #include<stdio.h> main() {

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

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

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

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

1. 1. B

2. G 3. Any node 4. Both a and b are correct 23. When fopen() fails to open a file it returns a) NULL b) 1 c) 1 d) None of the above 24. 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

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

Vous aimerez peut-être aussi