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

Class booking system, I want source code for class booking system by using ...

I want source code for class booking system by using C++ Programming...Urgent

C++ age guessing game, Write a program that predicts users’ age (0-128 year...

Write a program that predicts users’ age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an initial gues

Explain member functions of a class, Member Functions of a Class A memb...

Member Functions of a Class A member function of the class is similar as an ordinary function. Its declaration in a class template must explain its return value as well as the

Design a car management system application, 1) Database: The database nee...

1) Database: The database needs to be used for persistent storage of cars. For details of what information should be stored in the database, please see the description above. You

Destruction of array object, What's the order that objects in an array are ...

What's the order that objects in an array are destructed? Need assistance please explain it with example.

Develop diablo 2 lod 1.13d dupe method for closed battle.net, Develop Diabl...

Develop Diablo 2 LOD 1.13d Dupe Method for Closed Battle.net This hack is for diablo 2 lord of destruction The program must work on all realms, all cores, all ladders (4x rea

Employee payroll, You are to write a C++ program which will compute the gro...

You are to write a C++ program which will compute the gross pay, Social Security Tax, Income Tax and net pay for an employee. The program needs to prompt for and read the employ

Windows object code copy minder defeat, Project Description: We own prop...

Project Description: We own proprietary software which long ago had Copyminder protection added. We no longer have the source code or a relationship with the original coder and

Sort war - Sorting algorithms, If quicksort is so quick, why bother with an...

If quicksort is so quick, why bother with anything else? If bubble sort is so bad, why even mention it? For that matter, why are there so many sorting algorithms? Your mission (sho

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