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

Explain the symbolic constants in c language, Explain the Symbolic Constant...

Explain the Symbolic Constants in c language? Symbolic constants are the constants of any type that declared by using the #define compiler directive and it is a preprocessor di

Define the data file in c programming, Define the Data File in C Programmin...

Define the Data File in C Programming? Many applications needs that information can written to or read from an auxiliary memory device. Such information is stock up on the memo

Matematic, how to make program c++

how to make program c++

Board coloring, coloring of elements in matrix form inm particular matrix.t...

coloring of elements in matrix form inm particular matrix.the color should not match with another color.

Define the bitwise operators in c language, Define the Bitwise Operators in...

Define the Bitwise Operators in c language? C has distinction of supporting special operators that known as bit wise operators for manipulation of data at bit level. These oper

Explain difference between early binding and late binding, What is the diff...

What is the difference between early binding and late binding? What are advantages of early binding? a.) Late binding refers to function calls which aren't resolved until run t

Implementation of the stack class in c++, Implementation of the Stack class...

Implementation of the Stack class in C++: How to implement stack class in c++. int Stack::push(int elem) {    if (top    {       list[top++] = elem;       r

Program for design and simulate a basic risc processor, Overall Program Obj...

Overall Program Objective: You will design and simulate a basic RISC processor.   You will create and encode an instruction set.  Your final task will be to "compile" a program

Define variable declaration in c++, Variable Declaration This declarati...

Variable Declaration This declaration of variables in the C language is permitted only in the starting of their block, prior to executable program statements. In C++ declaratio

Area under a curve, Write a program to find the area under the curve y = f(...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

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