Knowledge Checks- Module 2

Write the output for the following programs: 1) What is the output of the following code? main() { int x; x=recs(10); printf(“x= %d”,x); } recs(i) int i; { static int s=0; if(i==15) { return(s); } else { sum=sum+3; i++; recs(i); } } a) b) c) d) x=5; x=1; x=15; error will be generated

Feedback: A) Incorrect. C is the correct answer. B) Incorrect. C is the correct answer C) Correct D) Incorrect. C is the correct answer

}. struct node * link. q = malloc(sizeof(struct node)). struct node * link. struct node *p. . *q.h” main() { struct node { int data.h” main() { struct node { double data. sizeof(p)).2) #include “alloc. } a) 4 b) 8 c) 2 d) 1 Feedback: A) Incorrect. C is the correct answer B) Incorrect. }. p = malloc(sizeof(struct node)). C is the correct answer C) Correct D) Incorrect. p = malloc(sizeof(struct node)). printf(“\n%d ”. p->data = 390. struct node *p. C is the correct answer 3) #include “alloc.

D is the correct answer C) Incorrect.p->link = q. printf(“\n%d “. p = p->link. } a) 390 390 b) 450 450 c) 390 NULL d) 390 450 Feedback: A) Incorrect. p->data). D is the correct answer D) Correct . p->data). printf(“\n%d “. q->link = NULL. q->data = 450. D is the correct answer B) Incorrect.