Iven the function below what would happen if the first


A.What is the output of the following program? Why?

#include
main() {
typedef union {
int a;
char b[10];
float c;
}Union;
Union x,y = {100};
x.a = 50;
strcpy(x.b,"hello");
x.c = 21.50;
printf("Union x : %d %s %f n",x.a,x.b,x.c);
printf("Union y : %d %s %f n",y.a,y.b,y.c);
}
B.Write a C program named sum.c that adds up its command line arguments, which are assumed to be integers. Running the program by typing:

sum 8 24 62

should produce the following output:

Total: 94

Your program should work for any number of typed in numbers.


C.Given the function below. What would happen if the first parameter would be struct node *list instead of struct node **list? Explain why.
void add_to_list(struct node **list, int n)
{
struct node *new_node;
new_node = malloc(sizeof(struct node));
if (new_node == NULL) {
printf("Error: malloc failed in add_to_list\n");
exit(EXIT_FAILURE);
}
new_node->value = n;
new_node->next = *list;
*list = new_node;
}
D. Modify the inventory2.c program by adding an e (erase) command that allows the user to remove a part from the database.

Please see the inventory2.c file

E.Write a program that reverses a singly linked list.


Attachment:- 321688_2_inventory2.rar

Solution Preview :

Prepared by a verified Expert
Software Engineering: Iven the function below what would happen if the first
Reference No:- TGS0650541

Now Priced at $40 (50% Discount)

Recommended (99%)

Rated (4.3/5)