Describe how a structure differs from a union, C/C++ Programming

Assignment Help:

Question :

(a) How does a structure differ from an array?

(b) Describe how a structure differs from a union?

(c) Declare a union called ‘clothes' which consists of the 3 members:-

1. manufacturer of type character and size 20
2. cost of type float
3. size of type character for e.g. S - small, M - medium, L- large and XL- extra large

Declare two variables-"blouse" and "shirt" of the type clothes.

(d) (i) Describe what is meant by a ‘nested structure'.

(ii) Prepare a piece of code to give an example of a nested structure.

(e) Define a structure consisting of two floating point members, called real and imaginary.

Include a tag called complex within the definition.

Declare three variables x1, x2 and x3 to be structures of type complex.

Assign the initial values of 1.3 and -2.2 to the members x.real and x.imaginary respectively.

(f) Define a union containing three members, each of type "dateTime", i.e. hour, minute and second. Then define a structure of type "calendarDate" containing three integer members , called day, month and year respectively. Declare a variable "date1" of type "calendarDate". Set the time of date1 to ‘10:30:25'.


Related Discussions:- Describe how a structure differs from a union

Function declarations and function definitions in cpp, FUNCTIONS It refe...

FUNCTIONS It refers to a subprogram that is meant to do a certain task. It is basically used to execute a set of operations and return information to the main or calling functio

Define some features of static storage class in c program, Define some feat...

Define some features of static storage class in c program? The features of a variable defined to contain a static storage class are as follows. Storage - memory Default

Program of libarary , #include #include using namespace std; class Book...

#include #include using namespace std; class Book { private: string title; int iD; int year_pub; string author; public: string getTitle(); int getId(); int getYear_Pub(); st

Return values, What is the purpose of return values? Can you not return any...

What is the purpose of return values? Can you not return any values from a function? If you could what would he function look like?

Common concepts of object oriented, Object Oriented Programming Paradigm: ...

Object Oriented Programming Paradigm: For OOP, Paradigm is a standard set.  The OOP will help to develop software in modules, which will be integrated later as a full packag

#c++ homework, write c++programm that converts degrees Kelvin (TK) to degr...

write c++programm that converts degrees Kelvin (TK) to degrees Fahrenheit(TR) recall that TF=(9/5)TK and that TF=TR-459.67

Give example of the do while loop, Normal 0 false false fal...

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

Explain increment and decrement operators, Increment and Decrement Operator...

Increment and Decrement Operators.   The operator for increment is '++' and decrement is '-'. These operators enhances or decrease the value of a variable on which they are ope

What is the use of default constructor, What is the use of default construc...

What is the use of default constructor? - It's a constructor that doesn't accept any parameters. - If there is no user-defined constructor for a class, compiler declares a d

C++ program, Receive 3 numbers and display them in ascending order from sma...

Receive 3 numbers and display them in ascending order from smallest to largest ed#

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd