What is a union how does it differ from a structure, C/C++ Programming

Assignment Help:

Question :

(a) (i) What is a structure member in C? What is the relationship between a structure member and the structure?
(ii) How can structure variables be declared in C? How do structure variable declarations differ from structure type declarations?
(iii) Can a structure variable be defined as a member of another structure? Can an array be included as a member of a structure? Can an array have structures as elements?

(b) Describe a structure that contains the following three members:

(i) an integer quantity called won
(ii) an integer quantity called lost
(iii) a floating-point quantity called percentage

Include the user-defined data type record within the definition.

(c) (i) What is a union? How does it differ from a structure?
(ii) How is a union member accessed?
(iii) How can a union member be processed?

(d) Define a union of type ans which contains the following three members:
(i) an integer quantity called ians
(ii) a floating-point quantity called fans
(iii) a double-precision quantity called dans

Now define a structure which contains the following four members:
(i) a union of type ans called answer
(ii) a single character called flag
(iii) two integer quantities called a and b

Finally declare two structure variables called x and y whose composition is as described above.


Related Discussions:- What is a union how does it differ from a structure

KRPano, I am seeking an expert to create a 360 degree virtual tour in KRPan...

I am seeking an expert to create a 360 degree virtual tour in KRPano for use on PCs, tablets and smartphones. You will be given with panoramas in order to create an advanced KRPano

Algorithm, Sine function computation

Sine function computation

Algorithem, algorithem of compound interest

algorithem of compound interest

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.

The Shell or Command Line Interpreter is the fundamental Use, 1. The shell ...

1. The shell must support the following internal commands: i. cd - Change the current default directory to . If the argument is not present, report the current directory. If t

Write program.., # Dear I want help to programmer that write C++ code for...

# Dear I want help to programmer that write C++ code for my small project as soon as posible If we can help me?..

Program of conversion from basic to user-defined variable, Conversion from ...

Conversion from Basic to User-Defined variable Consider the following example. class Distance                  {                   public  :

Pseudocode , Record separation problem Let us assume that a particular data...

Record separation problem Let us assume that a particular database program manages a simple mailing list which consists of one record for each person on the list, and a number of f

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