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

Use of a windows box, This program requires the use of a windows box, no co...

This program requires the use of a windows box, no console applications are allowed. Prepare for Christmas now.  Each year, Reindeer Gift Emporium publishes a Christmas price list

Explain structured programming, Explain structured programming The prin...

Explain structured programming The principal idea behind structured programming was as easy as the idea of "divide and conquer." A computer program could be regarded as having

Stone game, how to write a c program for stone game

how to write a c program for stone game

Single string programme, write a programme that allows a user to enter 5 di...

write a programme that allows a user to enter 5 distinct words and returns them as a single string

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

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

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

Define classes and objects, Classes and Objects A class is a vehicle to...

Classes and Objects A class is a vehicle to execute the OOP features in the C++ language. Once a class is declared, an object of that type can be explained. An object is said t

Area under the curve, Area under the curve Write a program to find the area...

Area under the curve 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 bet

Procedure-oriented programming, E v o l u t i o n of Software: ...

E v o l u t i o n of Software: In the past stage of programming the software's were developed in Machine language Using binary numbers 1's and 0's.  Later it convert

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