Professional Documents
Culture Documents
7 - 2 - Arrays of Structures
7 - 2 - Arrays of Structures
7 - 2 - Arrays of Structures
int main()
{
int i;
PayRec employee[NUMRECS] = {
{ 32479, "Abrams, B.", 6.72 },
{ 33623, "Bohm, P.", 7.54},
{ 34145, "Donaldson, S.", 5.56},
{ 35987, "Ernst, T.", 5.43 },
{ 36203, "Gwodz, K.", 8.72 }
};
Define array of 100 structures for each of the data types described:
Declare a structure data type named Stemp for each of the following records:
struct Stemp
{
int partNum;
char circuitFamily[40];
char functionType[40];
double supplyVolts;
int unitsInStock;
};
struct Stemp
{
char name[40];
double price;
char date[11]; // assuming the form is dd/mm/yyyy
};
struct Stemp
{
int partNum;
char desc[100];
int quant;
int reorder;
};
Include the array created in a program that displays the names and number of days in the week.
Include the array created in a program that displays the names and number of the days in the week.
#include <iostream>
using namespace std;
struct WeekDays
{
char name[MAXCHARS];
char dayNumber[MAXCHARS];
};
int main()
{
WeekDays convert[No_of_weekDays] = { {"Monday", "First"}, {"Tuesday", "Second"},
{"Wednesday", "Third"},{"Thursday", "Fourth"},
{"Friday", "Fifth"}, {"Saturday", "Sixth"},
{"Sunday","Seventh"}
};
int i;
return 0;
}
Using the data type shown below write a program that accepts a number of the day in a week from a user in
numerical form and displays the name of the day and the number of the day of the week. Thus in response to an
input of 3, the program would display Wednesday is third day of the week.
struct MonthDays
{
string name;
string dayNumber;
};