Question: 1) Translate the following flowchart to pseudocode. 2. Topics: Pointers, Linked-List, Scope, C-Function a) The following C program compiles, links without errors and should print

1) Translate the following flowchart to pseudocode.

1) Translate the following flowchart to pseudocode. 2. Topics: Pointers, Linked-List, Scope,

2. Topics: Pointers, Linked-List, Scope, C-Function a) The following C program compiles, links without errors and should print CMP10, but it produces segmentation faults when we run it. Identify the TWO errors in the code and suggest minimal changes that would allow the program to execute successfully. Your changes should not alter the general structure of the program, i.e. it should still link the two nodes in the main program into a linked list and print it. Indicate the line of code of each error, describe the error and give the correct code.

1: #include 2: #include 3: #include 4: 5: // linked list node for a list of c-strings 6: 7: typedef struct node { 8: char *data; //string data in this node 9: struct node *next; /ext node or NULL if none 10: } Node; 11: 12: // print strings in list that starts at head 13: void print(Node *head); //function prototype print 14: 15: // add x to front of strlist and return pointer to new list head 16: Node *push_node(Node x, Node *strlist); //function prototype push_node 17: 18: // link two nodes together as a list and then print the list 19: int main () { 20: Node n1; 21: Node n2; 22: Node *list = NULL; //head of linked list of NULL if empty 23: 24: // copy "10" to first node and push onto front of list 25: strcpy(n1.data, "1028"); 26: list = push_node(n1, list); 27: 28: // copy "CMP" to second node and push onto front of list 29: strcpy(n2.data, "CMP"); 30: list = push_node(n2, list); 31: 32: // print list 33: print(list); 34: return 0; 35: } 36: 37: // print strings in list that starts at head 38: void print(Node *head) { 39: Node *p = head; 40: 41: while (p != NULL) { 42: printf("%s", p->data); 43: p = p->next; 44: } 45: }

46: 47: // add x to front of strlist and return pointer to new list head 48: Node *push_node(Node x, Node *strlist) { 49: x.next= strlist; 50: return &x; 51: }

3. Based on the following program:

#include char *username = "SUCP"; double average( int *x, int n); int main(){ int z[5]; int i; for(i=0;i

i) Identify the local variables ii) Identify the global variables iii) Identify the formal parameters iv) Identify the actual parameters v) What is the output of the above program?

A? -YES- NO Do B Do E NO F? YES -YES Do G 1? Do J Np Do D

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!