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.
* I'm good till here.
In addition, declare a array named emp of 30 of these structures.
*this has me scratching my head is this Emp emp[30];
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 k'th element of emp (assume k has been declared as an integer variable and assigned a value in the range of the array elements).
struct Emp{
double d;
char *str;
int arr[11];
}emp[30];
emp[29].arr[10]=12;
emp[0].d=3.5;
emp[k].str="Hello";
Emp emp[30];
should work.
struct Emp
{
double d;
char *str;
int arr[11];
}e[30];
// assigning value 12 to the last element of the arr[11] of the last emp
e[30].arr[11] = 12;
// assign 3.5 to the d field of the first emp
e[0].d = 3.5;
//assuming k has value
strcpy(e[k].str,"hello");
To declare a structure named "Emp" with the specified fields and order, you can use the following code:
```c
struct Emp {
double d;
char* str;
int arr[11];
};
```
To declare an array named "emp" of 30 elements with the "Emp" structure, you can use the following code:
```c
struct Emp emp[30];
```
To assign the value 12 to the last element of the "arr" field of the last element of "emp", you can use the following code assuming the array is zero-indexed:
```c
emp[29].arr[10] = 12;
```
To assign the value 3.5 to the "d" field of the first element of "emp", you can use the following code:
```c
emp[0].d = 3.5;
```
To assign the string "Hello" to the k'th element of "emp" where k is an integer variable, you can use the following code:
```c
int k;
char* str = "Hello";
emp[k].str = str;
```
Make sure that the value of k is within the range of the array elements (0 to 29 in this case) to avoid accessing elements outside the array bounds.