0% found this document useful (0 votes)
20 views1 page

Assignment 4 (Structures)

The document discusses a C++ programming assignment involving structures and enumerations. It includes questions about printing values from an enumeration, declaring and initializing a variable of an enumerated type, defining and initializing a structure variable to represent time, creating and initializing a Volume structure to model room dimensions, and writing a program to calculate and display the difference between two time structures entered by the user.

Uploaded by

hassan tag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Assignment 4 (Structures)

The document discusses a C++ programming assignment involving structures and enumerations. It includes questions about printing values from an enumeration, declaring and initializing a variable of an enumerated type, defining and initializing a structure variable to represent time, creating and initializing a Volume structure to model room dimensions, and writing a program to calculate and display the difference between two time structures entered by the user.

Uploaded by

hassan tag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

MET 111 Computer and Programing Dr.

Abdelhady Mostafa

MET 111 Assignment #4 Structure

1. What does the following piece of code print?


int main()
{
enum channel {star, sony, zee};
enum symbol {hash, star};
int i = 0;
for (i = star; i <= zee; i++)
cout << i;
return 0;
}

2. Consider the following enumeration enum colors {black, blue,


green, cyan, red, purple, yellow, white}; Declare a variable of
this type and assign it to the value red.

3. Consider the following structure struct time {int hrs, mins, secs};
Define a structure variable time_now and initialize it to the current time at your
clock.

4. Create a structure called Volume that uses three variables of type Distance to model
the volume of a room. Initialize a variable of type Volume to specific dimensions
(Initialize), then calculate the volume it represents, and print out the result.

5. Write a Program to check Time Difference. Create a structure called time


that contains three members (Hours, minutes, Seconds). Ask the user to
Enter the starting and stopping time. Then, the program will will display the
difference in the same format hours, minutes and seconds.

Enter the starting time in (Hours: Minutes: Seconds)


3
12
45
Enter the Stopping time in (Hours: Minutes: Seconds)
5
10
11

You might also like