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

We need to decompile ex4 to mq4, We need to Decompile ex4 to mq4 I have ...

We need to Decompile ex4 to mq4 I have three expert advisors for mt4, which I need to decompile to its original mq4 code. Skills required are C Programming, C++ Programming,

Cloud computing, hi Bhasker, as we spoke tru phone ,we need a project usin...

hi Bhasker, as we spoke tru phone ,we need a project using cloud computing .we need to present a protoype or demo on it (any thing using cloud should be fine)(ex: P2p)

Board coloring, in this problem u given a board in which some of the eleme...

in this problem u given a board in which some of the elements are placed as shown in diagram below .each element represent a color .fill the other elements in the board such that n

Padovan string , .write a program that counts the number of occurrences of ...

.write a program that counts the number of occurrences of the string in the n-th padovan string p(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college

Object Oriented Programming , You are required to give C++ implementation o...

You are required to give C++ implementation of following classes: 1. PropertyCategories 2. Plot 3. Flat 4. House Following is the description of all data member and member funct

How the compiler arranges the several sections , Q: How the compiler arrang...

Q: How the compiler arranges the several sections in the executable image? A: The executable contained following sections: 1.      Data Section (initialized data variable sec

Write a function to calculate the exchange rate, Write a function to calcul...

Write a function to calculate the exchange rate of pounds to dollars  Answer       Td = 2xTp   The parameter passed over is the number of pounds and returned the value in do

Compiler Design - Limit In The Method Instructions, Raj is a newbie to the ...

Raj is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with ''}''

Evaluate the credit worthiness of a client, Write a C++ program that can be...

Write a C++ program that can be used to evaluate the credit worthiness of a client. The program reads the credit limit and the price and quantity of the item to be purchased by the

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