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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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<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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education