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.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)