Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Faculty of Engineering

Experiment Title : Structures

Subject : EE 209 Computing for Engineers

Course : Bachelor of Engineering (Hons) Civil Engineering

Name of Student : LEE JUN XIAN

Student ID No : 1001644955

Semester and Year : SEPTEMBER - November 2017 SEMESTER

Date of Experiment: 9/10/17

Date of Submission: 16/10/17

Name of Lecturer : Asst. Prof. Dr. Mastaneh Mokayef


Title of Experiment: Structures

Objectives:
To be familiar with using structures and arrays of structures.

Provide your answer to the questions including the screen shot of your output.

Equipment/Apparatus:

PC with C++ compiler

Precaution:

@<iostream> is used instead of <iostream.h> where <iostream.h> is an old version of


library which is not available for code block.
@Refer to the lab manual and follow the steps.

Analysis coding excecution:

In programming environment the problem solving process requires the following


steps.

Step 1. Analyze the problem, outline the problem and its solution requirements and
design an algorithm to solve the problem.

Step 2. Implement the algorithm (a step by step problem solving process in which a
solution is arrived at finite time) in a programming language such as c++ and verify
that the algorithm work.

Step 3. Maintain the program by using and modifying it if the problem domain
changes.
Question 1

Using the data type


struct MonthDays
{
string name;
int days;
};
define an array of 12 structures of type MonthDays. Name the array convert[], and
initialize the array with the names of the 12 months in a year and the number of days
in each month.
Using the data type
struct MonthDays
{
string name;
int days;
};
define an array of 12 structures of type MonthDays. Name the array convert[], and initialize
the array with the names of the 12 months in a year and the number of days in each month.
Question 2
Include the array created in a C++ program to display the names and number of days in each
month.

Sample Output:
Discussion:
As we know, C Structure is collection of different data types ( variables ) which are
grouped together. Whereas, array of structures is nothing but collection of structures.
This is also called as structure array in C.

Conclusion:
In conclusion ,student should able to be familiar with using structures and arrays of
structures. Student should code it carefully and step by step to avoid error occur
during programming .

You might also like