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

What is token in programming languages, T o k e n :  Tokens  are  s...

T o k e n :  Tokens  are  small  entities  in  a  program.    Example: identifiers,  keywords,  constants, operators, strings, etc.  These tokens are used almost in same wa

Program to determine the number is prime or not, Write a function to determ...

Write a function to determine whether a number is prime: it will return true if the input is prime and false otherwise. Use it to see whether -7 is prime.

Explain automatic variables, Automatic Variables Automatic variables ar...

Automatic Variables Automatic variables are variable which are explained within the functions. They lose their value when the function terminates. It can be accessed only in th

Explain pure virtual functions, Pure Virtual Functions An abstract clas...

Pure Virtual Functions An abstract class is one, which is used just for deriving some other classes. No object of this class is declared and used in the program. Likewise, ther

Pebble merchant problem, Problem Description There is a pebble merchant. H...

Problem Description There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometime

Hotel booking, Construct a console program to manage the booking of a Hotel...

Construct a console program to manage the booking of a Hotel room.

Strings, write a c program to find input string using strlen(), strcpy(), s...

write a c program to find input string using strlen(), strcpy(), strcat(),strncat(), strcmp().

Explain the working of strcmp and strcat function, Explain the working of s...

Explain the working of strcmp and strcat Function? strcmp() : This function is meant to use to compare two strings. The strcmp() function acknowledge two strings as argument

Define namespace in c++, It is a feature in C++ to reduce name collisions i...

It is a feature in C++ to reduce name collisions in the global name space. This namespace keyword assigns a separate name to a library that allows other libraries to use the simila

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