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

Loan negotiation is usually not a straightforward ta, Ask question #Minimum...

Ask question #Minimum 1Loan negotiation is usually not a straightforward task. A type of loan is the discount installment loan. This type of loan has the following characteristics.

Palindrome, string S convert it to a palindrome by doing chara, C/C++ Progr...

string S convert it to a palindrome by doing chara, C/C++ Programming

How can one make it so keys pressed through users are , How can one make it...

How can one make it so keys pressed through users are not echoed on the screen? A: It is not a standard C++ feature. C++ doesn't even need your system to have a keyboard or a sc

Class, array of class objects and single inheritance

array of class objects and single inheritance

Explalin concept of derivations in c++, derivations 1. Regardless of the...

derivations 1. Regardless of the type of derivation, private members are inherited by the derived class, but cannot be accessed by the new member function of the derived class,

Explain briefly about class and objects, Question 1. Explain Briefly ab...

Question 1. Explain Briefly about class and objects. 2. Create a class string which stores a string value. Overload ++ operator which converts the characters of the string t

C program to display the contents of file on a screen, Program is to displa...

Program is to display the contents of file on a screen: Write a program to display the contents of file on a screen void main()   {  clrscr();  ifstream fin("ascii

Insert values in queue - c++ program, Insert values in queue - C++ program:...

Insert values in queue - C++ program: Write a program to insert values in queue. int main()   {         int k;     Queue timeLine;     cout     for(

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