Menu

(Solved) : 1 Output Following C Program Explain Include Struct Node Int X Int Ptr Int Main Void Struc Q30455756 . . .

1. What is the output of the following C program and ExplainWHY???

#include <stdio.h> struct node {

int x;

int *ptr; };

int main(void){ struct node temp; struct node *sp = &temp; int x = 23; temp.x = 66; temp.ptr = &x; printf(“%d, %dn”, sp->x, *(*sp).ptr);

}

2. What is the output of the following C program and explainWHY?

#include <stdio.h> struct {

int k;

char c; };

int main() {

struct p; p.k = 20; p.c = 10; printf(“%dn”, p.k);

}

3. What is a node used for in a linked list(choose all thatapply)?

a. To store the information and the link to the next item.

b. To check for the end of the list.

c. Not used in a linked lists.

4. What is the output of the following C program and explainWHY????

#include <stdio.h>struct p{ int k; char c; float f;

};

int main() {

struct p x = {97, 65, 1}; printf(“%cn”, x.c);}

5. What is the output of the following C program and explainWHY????

#include <stdio.h>struct p{ int k; char c; float f;};int main(){ struct p x = {97, 65}; printf(“%.2fn”, x.f);}

6. What does the following fragment of code do with a linkedlists?

current = head;while (current != null) { current = current.next;}

7. The below C declaration define ‘s’ to be (choose thatapplies)

struct node {

int i;

float j; };

struct node *s[10];

a. An array, each element of which is a pointer to a structureof type node.

b. A structure of 2 fields, each field being a pointer to anarray of 10 elements.

c. A structure of 3 fields, an integer, a float, and an array of10 elements.

d. An array, each element of which is a structure of typenode.

5. What does the following function do for a given Linked Liststwith first node as head?

void fun1(struct node* head) { if(head == NULL) return; fun1(head->next); printf(“%d “, head->data); }

9. Which of the following is not a disadvantage to the usage ofarray?

a. Fixed Size

b. You know the size of the array prior to allocation.

c. Insertion based on position

d. Accessing elements at specified positions

10. Point out the error in the following code and explainWHY????

struct emp {

int ecode;

struct emp e;};

11. Point out the error in the following program?

#include<stdio.h>int main(){

struct emp {

char n[20];

int age; };

struct emp e1 = {“David”, 23}; struct emp e2 = e1; if(e1 == e2) printf(“The structures are equal”); return 0;

}

Expert Answer


Answer to 1 Output Following C Program Explain Include Struct Node Int X Int Ptr Int Main Void Struc Q30455756 . . .

OR