Question
5. What is the output of the following C program and explain WHY???? #include struct p { int k; char c; float f; }; int
5. What is the output of the following C program and explain WHY????
#includestruct p {
int k; char c; float f;
}; int main() {
struct p x = {97, 65};
printf("%.2f ", x.f); }
6. What does the following fragment of code do with a linked lists?
current = head; while (current != null) {
current = current.next; }
7. The below C declaration define 's' to be (choose that applies)
struct node {
int i;
float j; };
struct node *s[10];
a. An array, each element of which is a pointer to a structure of type node.
b. A structure of 2 fields, each field being a pointer to an array of 10 elements.
c. A structure of 3 fields, an integer, a float, and an array of 10 elements.
d. An array, each element of which is a structure of type node.
5. What does the following function do for a given Linked Listst with 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 of array?
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 explain WHY????
struct emp {
int ecode;
struct emp e; };
11. Point out the error in the following program?
#includeint 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;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started