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

Define the return statement in computer programming, Define The Return Stat...

Define The Return Statement in Computer Programming? The return statement is used for two purposes once the return statement is executed the program control will be immediately

C++, how do i write a c++ program that will input a number and output its f...

how do i write a c++ program that will input a number and output its factorial using the while loop

#Padovan string, A Padovan string P(n) for a natural number n is defined as...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of the c

Explain zero based addressing, Explain zero based addressing. - Array s...

Explain zero based addressing. - Array subscripts always start at zero. - These subscript values are used to identify elements in the array. - As subscripts start at 0, a

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Integration, w.a.p to find outWrite a program to find the area under the cu...

w.a.p to find outWrite 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.

Minimum shelfs, Write a program that finds the minimum total number of shel...

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Program to display appropriate message-clients accounts, Question A ban...

Question A bank normally updates it's clients accounts at the end of each month.Of the two types of bank accounts:savings and checking, a client must maintain a minimum balance

Define a procedure called make-avl-tree, This question deals with AVL trees...

This question deals with AVL trees. The representation to be used is similar to the bank account object discussed in class. (a) Define a procedure called make-avl-tree which mak

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