C

Topic: Structures and union

What is a structure?

A structure is a collection of pre-defined data types to create a user-defined data type. Let us say we need to create records of students. 

Each student has three fields:
int roll_number;
char name[30];
int total_marks;

This concept would be particularly useful in grouping data types. You could declare a structure student as:
struct student { 
int roll_number; 
char name[30]; int total_marks;
} 

student1, student2;

The above snippet of code would declare a structure by name student and it initializes two objects student1, student2. Now these objects and their fields could be accessed by saying student1. 

style='font-size:10.0pt;
font-family:"Courier New";color:#0000C0'>roll_number for accesing roll number field of student1 object, similarly student2. 

style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>name for accesing name field of student2 object.

Browse random answers:

What is a priority queue?
How to build an expression trees ?
How to convert Stack in to Queue and v varsa c with data structure.?
How do display the list in single linked list form last to first?
What is the easiest sorting method to use? 
What is the quickest sorting method to use? 
What is the quickest searching method to use? 
What is the difference between structure and union?
Can we initialize unions?
Why can’t we compare structures?
How are structure passing and returning implemented?
What is a structure?
What are the differences between structures and union?
What is a union?
What the advantages of using Unions?
which one is better structure or union?(other than the space occupied )
How will you free the allocated memory?
What is the difference between UNION and UNION ALL?
Describe structures and Union in brief.
What are the properties of Union? 
What the advantages of using Unions?
Difference between structure and union?
What is a structure and a union in C?
 What are bit fields? What is the use of bit fields in a Structure declaration?
Explain with an example the self-referential structure.
what is the similarity between a Structure, Union and enumeration?
What are bit fields? What is the use of bit fields in a Structure declaration?
What the advantages of using Unions?
How can we read/write Structures from/to data files?
"union" Data Type What is the output of the following program? Why?
Which is the best sorting method?
What's the difference between these two declarations?