Hello, Q: Declare a structure whose tag name is Emp and that contains these fields (in the following order): a double field named d, a character pointer named str, and an array of eleven integers named arr. In addition, declare a array named emp of 30 of these structures. Assign the value 12 to the last element of the arr field of the last element of emp. Assign 3.5 to the d field of the first emp element. Assign the string Hello to the kth element of emp (assume k has been declared as an integer variable and assigned a value in the range of the array elements). ========== My program however has errors, I would be grateful if you could correct them. What’s the difference between using emp[k].str="Hello"; vs. emp[k-1].str = "Hello"; ? ALSO, would your solution be like mine or do you have another way to do this? MY PROGRAM: #include struct Emp { double d; char *str; int arr[11]; }; int main(void) { emp[30]; emp[29].arr[10] = 12; emp[0].d = 3.5; emp[k].str="Hello"; return 0; } What’s the difference between using emp[k].str="Hello"; vs. emp[k-1].str = "Hello"; ? Thanks.
Hello,
Q:
Declare a structure whose tag name is Emp and that contains these fields (in the following order): a double field named d, a character pointer named str, and an array of eleven integers named arr. In addition, declare a array named emp of 30 of these structures. Assign the value 12 to the last element of the arr field of the last element of emp. Assign 3.5 to the d field of the first emp element. Assign the string Hello to the kth element of emp (assume k has been declared as an integer variable and assigned a value in the range of the array elements).
==========
My
ALSO, would your solution be like mine or do you have another way to do this?
MY PROGRAM:
#include<stdio.h>
struct Emp
{
double d;
char *str;
int arr[11];
};
int main(void)
{
emp[30];
emp[29].arr[10] = 12;
emp[0].d = 3.5;
emp[k].str="Hello";
return 0;
}
What’s the difference between using emp[k].str="Hello"; vs. emp[k-1].str = "Hello"; ?
Thanks.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images