Questions: 1. Would you prefer to use parallel arrays for id, age and salary or do you prefer an array of structures, and why? 2. How closely related is a structure in C to a schema in a database (you may have to research what a database schema is)? 3. What will be the output of the following program: #include struct course { int courseno; char coursename[25]; }; int main() { } struct course c] = {{102, "C"}, {103, "C++"}, {104, "Java"} }; printf("%d ", c[1].courseno); printf("%s\n", (*(c+2)).coursename); return 0;

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
Please answer it according to the code below #include #define MAX_EMP 5 struct Employee { int id; int age; float salary; }; int count = 0; struct Employee emp[MAX_EMP]; void display() { printf("\n---=== EMPLOYEE DATA ===---\n"); printf("EMP ID\tEMP AGE\tEMP SALARY\n"); printf("======\t=======\t==========\n"); for(int i = 0; i < count; i++) { printf("%d\t%d\t%.2f\n", emp[i].id, emp[i].age, emp[i].salary); } } void add() { if(count == MAX_EMP) { printf("\nERROR!!! Maximum Number of Employees Reached\n"); return; } printf("\nAdding Employee ===============\n"); printf("Enter Employee ID: "); scanf("%d", &emp[count].id); printf("Enter Employee Age: "); scanf("%d", &emp[count].age); printf("Enter Employee Salary: "); scanf("%f", &emp[count].salary); count++; } void update() { int id, found = 0; float newSalary; printf("\nUpdate Employee Salary ======================\n"); printf("Enter Employee ID: "); scanf("%d", &id); for(int i = 0; i < count; i++) { if(emp[i].id == id) { found = 1; printf("The current salary is %.2f\n", emp[i].salary); printf("Enter Employee New Salary: "); scanf("%f", &newSalary); emp[i].salary = newSalary; break; } } if(!found) { printf("* ERROR: Employee ID not found! *\n"); } } void Remove() { int id, found = 0, index; printf("\nRemove Employee ===============\n"); printf("Enter Employee ID: "); scanf("%d", &id); for(int i = 0; i < count; i++) { if(emp[i].id == id) { found = 1; index = i; break; } } if(!found) { printf("* ERROR: Employee ID not found! *\n"); return; } for(int i = index; i < count-1; i++) { emp[i] = emp[i+1]; } count--; printf("Employee %d will be removed\n", id); } int main() { int choice; while(1) { printf("\n1. Display Employee Information\n"); printf("2. Add Employee\n"); printf("3. Update Employee Salary\n"); printf("4. Remove Employee\n"); printf("0. Exit\n"); printf("\nEnter choice: "); scanf("%d", &choice); switch(choice) { case 0: printf("Exiting Employee Data Program. Good Bye!!!"); return 0; case 1: display(); break; case 2: add(); break; case 3: update(); break; case 4: Remove(); break; default: printf("ERROR: Incorrect Option: Try Again"); } } return 0; }
Questions:
1. Would you prefer to use parallel arrays for id, age and salary or do you prefer
an array of structures, and why?
2. How closely related is a structure in C to a schema in a database (you may have
to research what a database schema is)?
3. What will be the output of the following program:
#include <stdio.h>
struct course
{
int courseno;
char coursename[25];
};
int main()
{
}
struct course c] = {{102, "C"},
{103, "C++"},
(104, "Java"}
};
printf("%d ", c[1].courseno);
printf("%s\n", (*(c+2)).coursename);
return 0;
Transcribed Image Text:Questions: 1. Would you prefer to use parallel arrays for id, age and salary or do you prefer an array of structures, and why? 2. How closely related is a structure in C to a schema in a database (you may have to research what a database schema is)? 3. What will be the output of the following program: #include <stdio.h> struct course { int courseno; char coursename[25]; }; int main() { } struct course c] = {{102, "C"}, {103, "C++"}, (104, "Java"} }; printf("%d ", c[1].courseno); printf("%s\n", (*(c+2)).coursename); return 0;
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
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
  • SEE MORE 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