The document discusses structures and unions in C programming. It defines a structure as a user-defined data type that allows storing heterogeneous data under a single name. Structures contain members that can be accessed using the dot operator. Arrays of structures allow storing multiple records of the same type. Structures can be nested by defining a structure member within another structure. Unions allow storing different types of data in the same memory location, but only one member can be accessed at a time. Examples are provided to demonstrate defining, declaring, and accessing structure and union variables as well as nested structures.
C programming language allows data to be divided into different types including simple, structured, and user-defined types. Structures are a user-defined type that groups related data of different types under a single name. A structure is defined by specifying the data types and names of its members. Structure variables can be declared, initialized, and their members accessed using the dot operator. Arrays of structures and structures within structures can also be defined. Structures can be passed to and returned from functions.
The document discusses C programming concepts including structures, unions, and data types. It covers defining and using structures, with examples of declaring structure variables, initializing members, accessing members, structure assignment, arrays of structures, and structures within structures. It also discusses defining and using unions, and provides an example union definition and memory allocation. The document is made up of multiple lectures on these topics presented in Busy Bee workshops.
pointer, structure ,union and intro to file handlingRai University
This document provides information on structures in C programming language. It defines a structure called "employee" to store details of employees like ID, name, salary etc. It demonstrates how to declare and initialize structure variables, access structure members, pass structures to functions, return structures from functions, and create arrays of structures. The full code for a sample program implementing structures to store and print details of two employees is also provided.
The document discusses structures and unions in C programming. It begins by explaining why structures are used to group logically related data items of different types. It then defines a structure as a collection of one or more variables of different types grouped under a single name. The key aspects covered include:
- How to create a structure using the struct keyword and define members
- Declaring structure variables and initializing structure members
- Accessing structure members using dot operator
- Nested structures and arrays of structures
- Memory organization and copying of structure variables
- Unions share the same memory location for members unlike structures
The document provides examples to demonstrate defining structures and unions, declaring variables, initializing and accessing members, and comparing structures and
The document discusses structures and unions in C programming. It defines structures as collections of related data types under a single name, and unions as structures that allocate memory for the largest data type so all fields share the same memory location. The key points covered include declaring and defining structures with tags, accessing structure members, nested structures, arrays of structures, structures as function parameters and return values, and the differences between structures and unions in memory allocation and variable storage.
The document defines and explains structures in C programming. It discusses defining and declaring structures, accessing structure members, initializing structures, arrays of structures, structures within other structures, passing structures to functions, and the sizeof operator for structures. It also covers unions, accessing union members, and using bit fields to compactly store data in structures.
This document discusses structures in C++. It defines a structure as a collection of related data items that can be of different types. Structures allow grouping of data together, like elements in a student record. Individual structure members can be accessed using the dot operator. Arrays of structures and structures containing arrays are also discussed. Examples are provided to demonstrate defining, declaring, initializing, and assigning values to structures and nested structures.
Structures allow grouping of different data types under one name. To define a structure, the struct keyword is used followed by the structure tag name and a list of member variables enclosed in curly braces. Structures can be used to represent records in a database. Arrays of structures allow storing multiple records as array elements. Pointers to structures can be defined and used to access structure members using the arrow operator ->. Nested structures allow creating complex data types by defining one structure as a member of another structure.
C programming language allows data to be divided into different types including simple, structured, and user-defined types. Structures are a user-defined type that groups related data of different types under a single name. A structure is defined by specifying the data types and names of its members. Structure variables can be declared, initialized, and their members accessed using the dot operator. Arrays of structures and structures within structures can also be defined. Structures can be passed to and returned from functions.
The document discusses C programming concepts including structures, unions, and data types. It covers defining and using structures, with examples of declaring structure variables, initializing members, accessing members, structure assignment, arrays of structures, and structures within structures. It also discusses defining and using unions, and provides an example union definition and memory allocation. The document is made up of multiple lectures on these topics presented in Busy Bee workshops.
pointer, structure ,union and intro to file handlingRai University
This document provides information on structures in C programming language. It defines a structure called "employee" to store details of employees like ID, name, salary etc. It demonstrates how to declare and initialize structure variables, access structure members, pass structures to functions, return structures from functions, and create arrays of structures. The full code for a sample program implementing structures to store and print details of two employees is also provided.
The document discusses structures and unions in C programming. It begins by explaining why structures are used to group logically related data items of different types. It then defines a structure as a collection of one or more variables of different types grouped under a single name. The key aspects covered include:
- How to create a structure using the struct keyword and define members
- Declaring structure variables and initializing structure members
- Accessing structure members using dot operator
- Nested structures and arrays of structures
- Memory organization and copying of structure variables
- Unions share the same memory location for members unlike structures
The document provides examples to demonstrate defining structures and unions, declaring variables, initializing and accessing members, and comparing structures and
The document discusses structures and unions in C programming. It defines structures as collections of related data types under a single name, and unions as structures that allocate memory for the largest data type so all fields share the same memory location. The key points covered include declaring and defining structures with tags, accessing structure members, nested structures, arrays of structures, structures as function parameters and return values, and the differences between structures and unions in memory allocation and variable storage.
The document defines and explains structures in C programming. It discusses defining and declaring structures, accessing structure members, initializing structures, arrays of structures, structures within other structures, passing structures to functions, and the sizeof operator for structures. It also covers unions, accessing union members, and using bit fields to compactly store data in structures.
This document discusses structures in C++. It defines a structure as a collection of related data items that can be of different types. Structures allow grouping of data together, like elements in a student record. Individual structure members can be accessed using the dot operator. Arrays of structures and structures containing arrays are also discussed. Examples are provided to demonstrate defining, declaring, initializing, and assigning values to structures and nested structures.
Structures allow grouping of different data types under one name. To define a structure, the struct keyword is used followed by the structure tag name and a list of member variables enclosed in curly braces. Structures can be used to represent records in a database. Arrays of structures allow storing multiple records as array elements. Pointers to structures can be defined and used to access structure members using the arrow operator ->. Nested structures allow creating complex data types by defining one structure as a member of another structure.
Data Manipulation(DML) and Transaction Control (TCL) MuhammadWaheed44
A short course "SQL Fundamentals - Oracle 11g" is being in progress at PMAS Arid Agriculture University. Complete course video and can be found at following link
https://www.youtube.com/playlist?list=PL12t8CWUhXZaUXsmg7M67o_Q37JhhfAKU
This document summarizes the contents of Chapter 12 from a textbook on data structures. The chapter covers dynamic data structures like linked lists, stacks, and queues that allow for insertions and removals. It discusses self-referential structures using pointers to link nodes together into different data structures. Specific data structures covered include linked lists, which connect nodes via pointer links, stacks which only allow insertions and removals from one end, and queues which allow insertions at the back and removals from the front. The chapter also discusses dynamic memory allocation using functions like malloc and free to dynamically allocate and free memory for linked data structures. Sample code is provided to demonstrate creating and manipulating each of these common linked data structures.
The document contains code snippets demonstrating the use of structures and unions in C programming. The first code snippet defines a student structure and takes input from the user to populate the structure fields. The second snippet defines nested structures to store employee details including name, designation, address and salary. The third snippet defines a union to store marks in different subjects as well as total marks and percentage.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
USER DEFINED DATATYPES
STRUCTURE
UNION
TYPEDEF
DIFFERENCE BETWEEN STRUCTURE AND UNION
ENUMERATION (ENUM)
QUIZ SET 4
This document discusses structures and unions in C++. It defines a structure as a collection of related data items of different types stored together in memory. Structures allow defining custom data types that group various member variables. Unions also define custom data types but allow different types of variables to share the same memory space, taking up only as much space as its largest member. The document provides examples of declaring, defining, initializing, accessing members, and using structures and unions in C++ programs. It also compares the key differences between structures and unions.
This document discusses embedded SQL, functions, procedures, and triggers. Embedded SQL allows SQL statements to be embedded within host languages like C/C++ and Java. Functions and procedures can be written in SQL or an external language and used to perform calculations on data. Triggers are stored programs that automatically execute in response to data changes or other events. The document provides examples of how to create and use these database objects to query and manipulate data.
1) The document discusses different aspects of structures in C programming such as defining a structure, initializing structures, accessing structure members, arrays of structures, nested structures, and pointers to structures.
2) A structure allows grouping of different data types under a single name and is useful for representing records with multiple attributes of an entity.
3) Structures can contain other structures to represent nested relationships between entities. Pointers to structures allow structures to be passed to functions and returned from functions.
Structures allow the grouping of different data types together under one name. They are useful for storing records with multiple related data fields, like a student record with a name, roll number, and marks. Structures can be initialized, passed to functions by value or reference, and used to create arrays of records. Unions share the same memory location for different member types, while structures allocate separate memory for each member.
The document discusses various SQL integrity constraints and authorization commands. It describes primary key, foreign key, not null, check, unique, and default constraints that can be applied during table creation. It also covers the GRANT and REVOKE commands used to manage user permissions to tables. Examples are provided for each constraint and command to illustrate their proper syntax.
This document provides an introduction to SQL and the Oracle database system. It includes sections on SQL queries, data definition and modification, views, stored procedures and functions using PL/SQL, embedded SQL, integrity constraints, triggers, and database architecture. The document also references additional recommended literature for further learning about Oracle and SQL. It aims to provide a detailed overview of the core concepts for working with Oracle databases using SQL.
The document discusses structures and unions in C programming. It defines a structure as a user-defined data type that allows storing different data types together under a single name. A union shares the same memory location for all its members, while a structure allocates a unique memory location for each member. The document provides examples of declaring and initializing structures and unions, and accessing their members. It also compares key differences between structures and unions.
This document provides an overview of key concepts that will be covered in Lecture 2 of a Javascript course, including arrays, expressions and operators, functions, if/else and switch constructs, and loop constructs like for, while, and do-while loops. It also discusses data types in Javascript like integers, characters, strings, floats, and booleans. The summary defines arrays as collections of data of the same type with indexes starting at 0. It explains that functions are reusable blocks of code that can accept parameters and return values. Conditionals like if/else and switch-case are covered as constructs to control program flow based on conditions.
Arrays in C allows storing of similar data types in contiguous memory locations. The document provides code examples to initialize and traverse arrays, take user input to store in an array, calculate the average of numbers in an array, sort an array, and find the largest and second largest elements in an array. Functions like for loops, if statements and printfs are used to manipulate array elements.
The document discusses SQL DML commands like INSERT, UPDATE, and DELETE. It provides the syntax for these commands and examples of how to use them to manipulate data in database tables. Domain types in SQL like CHAR, VARCHAR, INT and DATE are also outlined. The document contains examples of creating tables, inserting data, updating and deleting rows with the DML commands in Oracle SQL.
Introduction, Array of structure, Passing structure to function, Passing array of structure to function, Structure within structure ( Nested Structure), Union, Pointer to structure
This document defines SQL data definition statements and basic SQL query structure. It discusses DDL statements like CREATE, ALTER, and DROP that are used to define and manage database structures. It also explains the typical components of an SQL query including the SELECT, FROM, and WHERE clauses. Finally, it outlines several set operations in SQL like UNION, UNION ALL, INTERSECT, and MINUS.
This document outlines the contents of a manual for a database management systems laboratory course. It covers 5 chapters on different lab programs involving creating database tables, inserting data, and writing queries. Chapter 1 provides an introduction to basic SQL commands including DDL, DML, TCL, and DCL commands. It describes commands like CREATE TABLE, ALTER TABLE, DROP TABLE, SELECT, INSERT, UPDATE, DELETE. Subsequent chapters provide the problem statements, ER diagrams, schema diagrams, code for creating tables and inserting sample data, and solutions to queries for 5 different database domains - library, orders, movies, college, and company.
The document discusses various aspects of structures in C programming language. It defines a structure as a collection of variables of different data types grouped together under a single name. Structures allow grouping of related data and can be very useful for representing records. The key points discussed include:
- Defining structures using struct keyword and accessing members using dot operator.
- Declaring structure variables and initializing structure members.
- Using arrays of structures to store multiple records.
- Nested structures to group related members together.
- Pointers to structures for dynamic memory allocation.
- Passing structures, structure pointers and arrays of structures to functions.
This document discusses structures and unions in C programming. It defines a structure as a user-defined data type that groups elements of different data types together under a single name. Structures allow members to be accessed and processed separately. Unions are similar to structures but all members share the same memory location, whereas structure members each have their own location. The document provides examples of defining, initializing, accessing structure members, passing structures to functions, pointers to structures, arrays of structures, and nested structures. It also compares the differences between structures and unions in terms of memory usage and member access.
This document discusses structures and unions in C programming. It begins by explaining that structures allow elements to differ in data type, unlike arrays where all elements are the same type. Structures are defined with the struct keyword followed by member names. Structure variables can then access members using the period operator. Unions similarly define multiple members but all share the same memory space, for efficient memory usage. Pointers to structures and unions can also be declared and used to access members. Functions can process entire structures by passing structure pointers.
Easy Understanding of Structure Union Typedef Enum in C Language.pdfsudhakargeruganti
This document discusses various C programming concepts related to structures, unions, enumerations, and typedef. It provides definitions and examples of each concept. Structures allow grouping of different data types under a single name. Unions share the same memory location for members. Enumerations define a user-defined data type of integer constants. Typedef allows defining an alias for existing data types. The document also discusses accessing structure members, nested structures, arrays of structures, passing structures to functions, self-referential structures, and bit fields.
Data Manipulation(DML) and Transaction Control (TCL) MuhammadWaheed44
A short course "SQL Fundamentals - Oracle 11g" is being in progress at PMAS Arid Agriculture University. Complete course video and can be found at following link
https://www.youtube.com/playlist?list=PL12t8CWUhXZaUXsmg7M67o_Q37JhhfAKU
This document summarizes the contents of Chapter 12 from a textbook on data structures. The chapter covers dynamic data structures like linked lists, stacks, and queues that allow for insertions and removals. It discusses self-referential structures using pointers to link nodes together into different data structures. Specific data structures covered include linked lists, which connect nodes via pointer links, stacks which only allow insertions and removals from one end, and queues which allow insertions at the back and removals from the front. The chapter also discusses dynamic memory allocation using functions like malloc and free to dynamically allocate and free memory for linked data structures. Sample code is provided to demonstrate creating and manipulating each of these common linked data structures.
The document contains code snippets demonstrating the use of structures and unions in C programming. The first code snippet defines a student structure and takes input from the user to populate the structure fields. The second snippet defines nested structures to store employee details including name, designation, address and salary. The third snippet defines a union to store marks in different subjects as well as total marks and percentage.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
USER DEFINED DATATYPES
STRUCTURE
UNION
TYPEDEF
DIFFERENCE BETWEEN STRUCTURE AND UNION
ENUMERATION (ENUM)
QUIZ SET 4
This document discusses structures and unions in C++. It defines a structure as a collection of related data items of different types stored together in memory. Structures allow defining custom data types that group various member variables. Unions also define custom data types but allow different types of variables to share the same memory space, taking up only as much space as its largest member. The document provides examples of declaring, defining, initializing, accessing members, and using structures and unions in C++ programs. It also compares the key differences between structures and unions.
This document discusses embedded SQL, functions, procedures, and triggers. Embedded SQL allows SQL statements to be embedded within host languages like C/C++ and Java. Functions and procedures can be written in SQL or an external language and used to perform calculations on data. Triggers are stored programs that automatically execute in response to data changes or other events. The document provides examples of how to create and use these database objects to query and manipulate data.
1) The document discusses different aspects of structures in C programming such as defining a structure, initializing structures, accessing structure members, arrays of structures, nested structures, and pointers to structures.
2) A structure allows grouping of different data types under a single name and is useful for representing records with multiple attributes of an entity.
3) Structures can contain other structures to represent nested relationships between entities. Pointers to structures allow structures to be passed to functions and returned from functions.
Structures allow the grouping of different data types together under one name. They are useful for storing records with multiple related data fields, like a student record with a name, roll number, and marks. Structures can be initialized, passed to functions by value or reference, and used to create arrays of records. Unions share the same memory location for different member types, while structures allocate separate memory for each member.
The document discusses various SQL integrity constraints and authorization commands. It describes primary key, foreign key, not null, check, unique, and default constraints that can be applied during table creation. It also covers the GRANT and REVOKE commands used to manage user permissions to tables. Examples are provided for each constraint and command to illustrate their proper syntax.
This document provides an introduction to SQL and the Oracle database system. It includes sections on SQL queries, data definition and modification, views, stored procedures and functions using PL/SQL, embedded SQL, integrity constraints, triggers, and database architecture. The document also references additional recommended literature for further learning about Oracle and SQL. It aims to provide a detailed overview of the core concepts for working with Oracle databases using SQL.
The document discusses structures and unions in C programming. It defines a structure as a user-defined data type that allows storing different data types together under a single name. A union shares the same memory location for all its members, while a structure allocates a unique memory location for each member. The document provides examples of declaring and initializing structures and unions, and accessing their members. It also compares key differences between structures and unions.
This document provides an overview of key concepts that will be covered in Lecture 2 of a Javascript course, including arrays, expressions and operators, functions, if/else and switch constructs, and loop constructs like for, while, and do-while loops. It also discusses data types in Javascript like integers, characters, strings, floats, and booleans. The summary defines arrays as collections of data of the same type with indexes starting at 0. It explains that functions are reusable blocks of code that can accept parameters and return values. Conditionals like if/else and switch-case are covered as constructs to control program flow based on conditions.
Arrays in C allows storing of similar data types in contiguous memory locations. The document provides code examples to initialize and traverse arrays, take user input to store in an array, calculate the average of numbers in an array, sort an array, and find the largest and second largest elements in an array. Functions like for loops, if statements and printfs are used to manipulate array elements.
The document discusses SQL DML commands like INSERT, UPDATE, and DELETE. It provides the syntax for these commands and examples of how to use them to manipulate data in database tables. Domain types in SQL like CHAR, VARCHAR, INT and DATE are also outlined. The document contains examples of creating tables, inserting data, updating and deleting rows with the DML commands in Oracle SQL.
Introduction, Array of structure, Passing structure to function, Passing array of structure to function, Structure within structure ( Nested Structure), Union, Pointer to structure
This document defines SQL data definition statements and basic SQL query structure. It discusses DDL statements like CREATE, ALTER, and DROP that are used to define and manage database structures. It also explains the typical components of an SQL query including the SELECT, FROM, and WHERE clauses. Finally, it outlines several set operations in SQL like UNION, UNION ALL, INTERSECT, and MINUS.
This document outlines the contents of a manual for a database management systems laboratory course. It covers 5 chapters on different lab programs involving creating database tables, inserting data, and writing queries. Chapter 1 provides an introduction to basic SQL commands including DDL, DML, TCL, and DCL commands. It describes commands like CREATE TABLE, ALTER TABLE, DROP TABLE, SELECT, INSERT, UPDATE, DELETE. Subsequent chapters provide the problem statements, ER diagrams, schema diagrams, code for creating tables and inserting sample data, and solutions to queries for 5 different database domains - library, orders, movies, college, and company.
The document discusses various aspects of structures in C programming language. It defines a structure as a collection of variables of different data types grouped together under a single name. Structures allow grouping of related data and can be very useful for representing records. The key points discussed include:
- Defining structures using struct keyword and accessing members using dot operator.
- Declaring structure variables and initializing structure members.
- Using arrays of structures to store multiple records.
- Nested structures to group related members together.
- Pointers to structures for dynamic memory allocation.
- Passing structures, structure pointers and arrays of structures to functions.
This document discusses structures and unions in C programming. It defines a structure as a user-defined data type that groups elements of different data types together under a single name. Structures allow members to be accessed and processed separately. Unions are similar to structures but all members share the same memory location, whereas structure members each have their own location. The document provides examples of defining, initializing, accessing structure members, passing structures to functions, pointers to structures, arrays of structures, and nested structures. It also compares the differences between structures and unions in terms of memory usage and member access.
This document discusses structures and unions in C programming. It begins by explaining that structures allow elements to differ in data type, unlike arrays where all elements are the same type. Structures are defined with the struct keyword followed by member names. Structure variables can then access members using the period operator. Unions similarly define multiple members but all share the same memory space, for efficient memory usage. Pointers to structures and unions can also be declared and used to access members. Functions can process entire structures by passing structure pointers.
Easy Understanding of Structure Union Typedef Enum in C Language.pdfsudhakargeruganti
This document discusses various C programming concepts related to structures, unions, enumerations, and typedef. It provides definitions and examples of each concept. Structures allow grouping of different data types under a single name. Unions share the same memory location for members. Enumerations define a user-defined data type of integer constants. Typedef allows defining an alias for existing data types. The document also discusses accessing structure members, nested structures, arrays of structures, passing structures to functions, self-referential structures, and bit fields.
The document discusses structures in C programming. It defines a structure as a collection of variables of different data types grouped together under a single name. Structures allow grouping of logically related data. Variables of a structure type are declared and each one contains its own copy of member variables. Members are accessed using the dot operator. Arrays of structures can be used to store multiple records. Nested structures allow a structure to contain another structure as a member.
This document discusses using structures in C programming to store student records. It defines a student structure with roll number, name, and marks members. A program is provided that uses a structure array to store records for 10 students, reading input and then displaying the stored information. The key aspects of defining structures, declaring structure variables, accessing structure members, and allocating structure memory are explained. Sample problems are given to practice using structures to store book information and add distances.
data structure and c programing conceptskavitham66441
A structure allows grouping of different data types under a single name. It can be used to represent a record by defining members for each attribute. Structures support defining arrays of structures to group multiple records together. Unions share memory between members and only one member can be accessed at a time, while structures have independent memory for each member. Pointers store the address of a variable and allow dynamic memory allocation by changing which variable an address points to.
● Concept of Structure and Union
● Declaration and Initialization of structure and union
● Nested structures
● Array of Structures
● Passing structure to functions
The document discusses different data types in C programming language including primary, derived, and user-defined data types. It explains what structures are and how to define, declare, and access structure variables. Structures allow grouping of different data types under a single name to represent complex user-defined data types like a record. The document provides examples of defining simple and nested structures, arrays of structures, and accessing structure members using pointers. It also discusses some common programming problems that can be solved using structures.
Structures in Functions discusses pointers to structures, accessing structure members, passing structures as function arguments by value and by reference, returning structures from functions, arrays of structures, and self-referential structures. Key points include passing a pointer to a structure as a function argument to avoid copying large structures, defining an array of structures to store multiple records, and using a pointer as a member of a structure to create self-referential linked structures like linked lists.
The document discusses structures in the C programming language. It defines a structure as a collection of variables of different data types under a single name. Structures allow grouping of related data and treating it as a single unit. The document covers defining structures, initializing structure variables, accessing structure members using dot operators, passing structures to functions, and nested structures. It provides examples of declaring, defining and using structures to store and process student records.
Data Structure & Algorithm - Self Referentialbabuk110
The document discusses structures in C programming. It defines a structure as a collection of logically related data items of different datatypes grouped together under a single name. Some key points discussed include:
- Structures allow user-defined datatypes that can group different data types together.
- Structures are defined using the struct keyword followed by the structure name and members.
- Structure variables are declared to use the structure datatype. Arrays of structures can also be defined.
- Members of a structure can be accessed using the dot (.) operator or arrow (->) operator for pointers to structures.
The document provides examples of defining, declaring, and accessing structure variables and members.
The document discusses structures in C programming. Some key points covered include: defining a structure with member variables of different data types; declaring structure variables; accessing structure members using the dot operator; arrays of structures; passing structures to functions; and nested structures. Examples are provided for each concept.
A structure is a collection of variables referenced under one name providing a convenient means of keeping related information together. The structure definition creates a format that may be used to declare structure variables in a program later. data structure in c questions and answer
Structures allow users to define custom data types that can store multiple related data items under one name. Structures are useful for storing records like student records that contain related fields. Structures can contain basic data types as well as other structures, allowing for nested structures. Structures can be passed to functions by passing individual fields or the entire structure. Macros provide a way to define symbolic constants and perform simple text substitution before compilation.
Diploma ii cfpc- u-5.3 pointer, structure ,union and intro to file handlingRai University
The document discusses C programming concepts including data types, structures, unions, pointers, and file handling. It provides examples of defining and using structures and unions to organize related data. Structures allow grouping of different data types under one name, while unions allocate space of the largest member. Pointers and arrays of structures are also demonstrated. Functions can pass, return, and access values in structures.
The document discusses structures and unions in C programming. It defines a structure as a user-defined data type that groups together related data of different types under a single name. A union is similar to a structure but can only store one data member at a time as it allocates memory for the largest data type. The key points covered include declaring and initializing structures and unions, accessing structure members, arrays of structures, structures within structures, and comparing structures and unions.
Structures allow grouping of related data types together under one name. They can contain members of different data types. Structures can be nested by defining one structure as a member of another. Members are accessed using the dot operator. Structures are initialized when declared and one structure can be assigned to another of the same type by copying member values. Examples demonstrate declaring, defining, initializing, accessing, and assigning structures.
The document discusses structures in C programming. It defines a structure as a collection of variables of different data types grouped together under a single name. Structures allow programmers to group logically related data as a user-defined data type. The document provides examples of defining structures for students, employees, products and time. It also covers declaring structure variables, accessing structure members using the dot operator, and differences between structures, arrays and unions.
Structures-Declaring and Initializing, Nested structure, Array of Structure, Passing Structures to functions, Unions, typedef, enum, Bit fields.
Pointers: Declarations, Pointer arithmetic, Pointers and functions, call by value, Call by reference, Pointers and Arrays, Arrays of Pointers, Pointers and Structures. Meaning of static and dynamic memory allocation, Memory allocation functions.
Files: File modes, File functions, and File operations, Text and Binary files, Command Line arguments Preprocessor directives. Macros: Definition, types of Macros, Creating and implementing user defined header files
The document discusses different data structures in C++ including structures, nested structures, typedef, enumerated data types, and macros. It explains that a structure allows grouping of related data types under one name and can be treated as a user-defined data type. It provides examples of declaring structure variables, defining members, and accessing members. Nested structures allow structures to be members of other structures. Typedef provides an alternative name for standard data types. Enumerated data types define a set of names mapped to integer constants. Macros allow defining symbolic names and constants using the #define preprocessor directive.
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
Batteries -Introduction – Types of Batteries – discharging and charging of battery - characteristics of battery –battery rating- various tests on battery- – Primary battery: silver button cell- Secondary battery :Ni-Cd battery-modern battery: lithium ion battery-maintenance of batteries-choices of batteries for electric vehicle applications.
Fuel Cells: Introduction- importance and classification of fuel cells - description, principle, components, applications of fuel cells: H2-O2 fuel cell, alkaline fuel cell, molten carbonate fuel cell and direct methanol fuel cells.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
Unit 5 (1)
1. 1
INDEX
Unit -5 CONTENT PAGE NO
Introduction 2
need for structure data type 3
structure definition 2
Structure declaration 2
Structure within a structure 11
Union 16
Programs using structures
and Unions
20
Storage classes 20
Pre-processor directives 25
2. 2
UNIT V STRUCTURES AND UNIONS 9
Introduction – need for structure data type – structure definition – Structure declaration – Structure
within a structure - Union - Programs using structures and Unions – Storage classes, Pre-process or
directives.
UNIT V
STRUCTURES AND UNIONS
Structure
In C programming , the various data types are
• Simple Data type
Integer, Real, Void, Char
• Structured Data type
Array, Strings
• User Defined Data type
Structures, Unions ,Enum
A structure is a user defined data type which allows you to combine data items of
different kinds into a single unit. All the elements of a structure are stored at contiguous
memory locations. i.e., store heterogeneous data under unique name.
Keyword 'struct' is used to declare structure. The variables which are declared inside
the structure are called as 'members of structure'.
Member of the structure variables can be initialized. The initialization for each
variable must be enclosed in braces. Note that there is a semicolon after the closing curly
brace.
Syntax:
struct structure_nm
{
<data-type> element 1;
<data-type> element 2;
3. 3
- - - - - - - - - - -
<data-type> element n;
}struct_var;
Example :
struct emp_info
{
char emp_id[10];
char nm[100];
float sal;
}emp;
Note :
1. Structure is always terminated with semicolon (;).
2. Structure name as emp_info can be later used to declare structure variables of its
type in a program.
Need for a structures
Structures makes a program to be modular program.
- Easier to modify.
Structure are used for whenever a lot of data needs to be grouped together—address book.
INSTANCES OF STRUCTURE :
Instances of structure can be created in two ways as,
Instance 1:
4. 4
struct emp_info
{
char emp_id[10];
char nm[100];
float sal;
}emp;
Instance 2:
The syntax of declaring a structure is
struct <struct_name> <variable_name>;
struct emp_info
{
char emp_id[10];
char nm[100];
float sal;
};
struct emp_info emp;
In above example, emp_info is a simple structure which consists of stucture members as
Employee ID(emp_id), Employee Name(nm), Employee Salary(sal).
ACEESSING STRUCTURE MEMBERS :
The structure members cannot be directly accessed. Structure members can be
accessed using member access operator ('.') . It is also called as 'dot operator' or 'period
operator'.
The syntax : the name of structure variable followed by a dot and then the name of
member variable.
5. 5
structure_var . member var;
To display a single person as a employee, the following program explains
/* details of an employee */
#include <stdio.h>
#include <conio.h>
struct emprec
{
char ename[100];
char eaddr[100];
}emp;
void main()
{
clrscr();
printf("n Enter employee Name : ");
gets(emp.ename);
printf("n Enter Address : ");
gets(emp.eaddr);
printf("nn employee Name : %s",emp.ename);
printf("nn Address : %s",emp.eaddr);
getch();
}
output
Enter employee Name : Saravanan
Enter Address : Madurai
6. 6
Enter employee Name : Pandiarajan
Address : Madurai
Ex: Similarly a student record
/* to store information of single record */
#include <stdio.h>
struct student{
char name[50];
int rollno;
float marks;
};
int main(){
struct student s;
printf("Enter student record:nn");
printf("Enter name: ");
scanf("%s",s.name);
printf("Enter roll number: ");
scanf("%d",&s.rollno);
printf("Enter marks: ");
scanf("%f",&s.marks);
printf("n printing n");
printf("Name: %sn",s.name);
printf("Roll: %dn",s.rollno);
printf("Marks: %.2fn",s.marks);
return 0;
}
output
7. 7
Enter student record :
Enter name : Saravanan
Enter roll number : 104
Enter marks : 87
Printing
Name : Saravanan
Roll no: 104
Marks : 87
ARRAY OF STRUCTURES:
The array of structure is used to store the large number of similar records. For
example to store the record of 10 employees then array of structure is used.
Defining array of structure:
The method to define and access array of structure is similar to array.
The syntax to define the array of structure is
Struct <struct_name> <var_name> <array_name> [<indexvalue>];
Example:-
Struct student stu[10];
Example:
/* to display 5 subjects of a student */
#include <stdio.h>
#include <conio.h>
8. 8
struct student
{
int rno, mrks[5];
char name;
}stu;
void main()
{
int i,total;
clrscr();
total = 0;
printf("nt Enter Roll Number : ");
scanf("%d",&stu.rno);
printf("nt Enter Marks of 3 Subjects : ");
for(i=0;i<3;i++)
{
scanf("%d",&stu.mrks[i]);
total = total + stu.mrks[i];
}
printf("nnt Roll Number : %d",stu.rno);
printf("nnt Marks are :");
for(i=0;i<3;i++)
{
printf(" %d",stu.mrks[i]);
}
printf("nnt Total is : %d",total);
getch();
}
Output
Enter Roll Number : 1
9. 9
Enter Marks of 3 Subjects : 63 66 68
Roll Number : 1
Marks are : 63 66 68
Total is : 197
In this program, a structure(student) is created which contains roll no and
marks as its data member. Then, a structure variable(stu) is created. Then, data ( roll
no and marks) is taken from user and stored in data members of structure variable stu.
Using this stu variable, the data to be displayed in the screen.
Similarly we print n students mark statement as array of structure.
/* To print students mark statement*/
#include"stdio.h"
#include"conio.h"
struct student
{
char name[25],grade;
int reg_no[15];
int s1,s2,s3,s4,s5,total;
float avg;
}st[10];
void main()
{
int i,n,total;
float avg;
printf("n Enter the no of Students:");
scanf("%d",&n);
printf("n Enter the name, regno and 5 subject marks:");
10. 10
for(i=0;i<n;i++)
{
printf("n Enter the name, regno and 5 sub marks”,%d",i+1);
scanf("%s%d%d%d%d%d%d", &st[i].name, &st[i].reg_no, &st[i].s1, &st[i].s2, &st[i].s3,
&st[i].s4, &st[i].s5);
st[i].total=st[i].s1+st[i].s2+st[i].s3+st[i].s4+st[i].s5;
st[i].avg=st[i].total/5;
if((st[i].s1<50)||(st[i].s2<50)||(st[i].s3<50)||(st[i].s4<50)||(st[i].s5<50))
{
st[i].grade='U';
printf("Ur grade is %c", st[i].grade);
}
else
{
st[i].grade='P';
printf("Ur grade is %c", sa[i].grade);
}
}
}
In this program, a structure(student) is created which contains name,regno and
5 marks as its data member. Then, a structure variable(st) is created. Then, data
name, regno and 5 marks of 10 students is taken from user and stored in data
members of structure variable st.
Using this stu variable, the data to be displayed in the screen.
Output:
Enter the no of Students: 2
Enter the name, regno and 5 subject marks:
100
11. 11
Deepa
50
50
50
50
50
Ur grade is P
Enter the name, regno and 5 subject marks:
101
Sasi
34
50
50
50
50
Ur grade is: U
STRUCTURES WITHIN STRUCTURES (NESTED STRUCTURES) :
Structures can be used as structures within structures. It is also called as 'nesting of
structures'.
Defining structures within structures:
Define a variable of structure type as a member of other structure type.
The syntax to define the structure within structure is
struct structure_nm
{
<data-type> element 1;
12. 12
<data-type> element 2;
- - - - - - - - - - -
- - - - - - - - - - -
<data-type> element n;
struct structure_nm1
{
<data-type> element 1;
<data-type> element 2;
- - - - - - - - - - -
- - - - - - - - - - -
<data-type> element n;
}inner_struct_var;
}outer_struct_var;
This tag explains nested structures.
struct stud_Res
{
int rno;
char nm[50];
char std[10];
struct stud_subj
{
char subjnm[30];
int marks;
}subj;
}result;
Accessing structures within structures
13. 13
Accessing inner structures within outer structure is accessed by using two period (.) symbol
The syntax to access the structure within structure is
struct _var. nested_struct_var. struct_member;
Example :
Emp.address.city;
/* to display marks structure with in student structure */
#include <stdio.h>
#include <conio.h>
struct stud_Res
{
int rno;
char std[10];
struct stud_Marks
{
char subj_nm[30];
int subj_mark;
}marks;
}result;
void main()
{
clrscr();
printf("nt Enter Roll Number : ");
scanf("%d",&result.rno);
printf("nt Enter Standard : ");
14. 14
scanf("%s",result.std);
printf("nt Enter Subject Code : ");
scanf("%s",result.marks.subj_nm);
printf("nt Enter Marks : ");
scanf("%d",&result.marks.subj_mark);
printf("nnt Roll Number : %d",result.rno);
printf("nnt Standard : %s",result.std);
printf("nSubject Code : %s",result.marks.subj_nm);
printf("nnt Marks : %d",result.marks.subj_mark);
getch();
}
Output
Enter Roll Number : 1
Enter Standard : MCA(Sci)-I
Enter Subject Code : SUB001
Enter Marks : 63
Roll Number : 1
Standard : MCA(Sci)-I
Subject Code : SUB001
Marks : 63
Pointers & Structures
We can also define a pointer variable of structure type. The syntax to define the
pointer to structure as same as pointer type.
struct <struct_name> *<pointer_var_name>;
Example:
15. 15
struct student *stu;
stu – pointer variable of student structure.
Access the Pointer - Structures
It is accessed by using the pointer variable followed with arrow operator() .
The syntax to access the pointer - structure.
pointer_var structure_member;
Example:
stuname;
Here “name” structure member is accessed through pointer variable stu.
16. 16
UNION :
Union is user defined data type used to stored data under unique variable name at
single memory location. Union holds value for one data type which requires larger storage
among their members.
Union follows the same syntax as structure with a major difference in terms of
storage. In structure every structure elements has their own storage location, whereas in union
all the members share the same location. So in a union there may be a number of elements
but only one member can be used at a time.
It defines different types of variable to share same space in memory.
To declare union data type, 'union' keyword is used.
Syntax:
union union_name
{
<data-type> element 1;
<data-type> element 2;
<data-type> element 3;
}union_variable;
Example:
union employee
{
int empid;
char name[20];
float salary;
}emp;
17. 17
In above example, it declares emp variable of type union. The union contains three
members as data type of int, char, float. We can use only one of them at a time.
MEMORY ALLOCATION :
Memory allocation for union
To access union members, we can use the following syntax.
Emp.empid
Emp.name
Emp.salary
Empid
salary
name
18. 18
Example:
#include <stdio.h>
#include <conio.h>
union employee
{
int id;
char name[50];
}emp;
void main()
{
clrscr();
printf("nt Enter employee id : ");
scanf("%d", &emp.id);
printf("nnt Enter employee name : ");
scanf("%s", emp.name);
printf("nn Employee ID : %d", emp.id);
printf("nn Employee Name : %s", emp.name);
getch();
}
output
Enter employee id : 101
Enter employee name : madhus
Employee ID : 101
Employee name : madhus
19. 19
Like structure members, we can access union members with statements like var.i,var.b, var.c.
While accessing value from an union member, we should make sure that we are accessing the
member in which the last value is assigned.
Difference between Structures & Union
Structure Union
We can access all the members of structure
at anytime.
Only one member of union can be accessed at
anytime.
Memory is allocated for all variables.
Allocates memory for variable which variable
require more memory.
All members of structure can be initialized
Only the first member of a union can be
initialized.
'struct' keyword is used to declare structure. 'union' keyword is used to declare union.
struct struct_name
{
structure element 1;
structure element 2;
----------
----------
structure element n;
}struct_var_nm;
union union_name
{
union element 1;
union element 2;
----------
----------
union element n;
union_var_nm;
eg
struct student
eg:
union student
20. 20
{
int marks;
float average;
char name[10];
memory allocation
int -2
float -4
name-10
total memory allocation=2+4+10
{
int marks;
float average;
char name[10];
memory allocation
only 10 bytes of memory will be allocated since
name data type will occupy maximum space of
memory over other data types
Advantages of union over structures
Union save memory space because the size of the union is equal to its largest sized
member.The size of the structure is the sum of the sizes of all structure members. So
Structure occupies a large space. Union are useful when there is a need to use only one of its
member at a time, But structure is used when there is a need to use all its members in a
program.
Storage classes
A storage class defines the scope (visibility) and life time of variables and/or
functions within a C Program.
21. 21
Local(internal) variables: are those which are declared within a particular function.
Global(external) variables: are those which are declared outside any function.
There are following storage classes which can be used in a C Program
auto
register
static
extern
auto - Storage Class
auto is the default storage class for all local variables.
Ex: auto int age;
This variable are private (local) to the function in which they are declared. If automatic
variables are not initialized they will contain garbage.
Program
#include <stdio.h>
int main()
{
int a=10;
check();
printf(“%dn”,a);
}
check()
{
int a = 5;
printf(“%dn”,a);
22. 22
}
Output:1
5
10
register - Storage Class
1. register is used to define local variables that should be stored in a register instead of
RAM. These variables are stored in one of the machine’s register and are declared
using register keyword. This is generally used for faster access.
Ex: register int m;
Program
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
register int c;
clrscr();
printf("nEnter the Number 1 : ");
scanf("%d",&a);
printf("nEnter the Number 2 : ");
scanf("%d",&b);
c=a+b;
printf("nSum is : %d",c);
23. 23
getch();
return(0);
}
Output
Enter the Number 1 :5
Enter the Number 2 :7
Sum is :11
Explanation
we have declared two variables a,b. These two variables are stored in RAM. Another
variable c is declared which is stored in register variable.Register variables are stored in the
register of the microprocessor.Thus memory access will be faster than other variables.
Static - Storage Class
static is the default storage class for global variables. Static variables are initialized
only once, when the program is compiled.
Ex: static int count;
/* static variable */
#include <stdio.h>
int main(){
Check();
Check();
}
void Check(){
24. 24
static int count=0;
printf("%d",count);
count+=5;
}
Output:
0
5
extern - Storage Class
extern is used to give a reference of a global variable that is visible to ALL the program
files.
Ex: extern int count;
External variable can be accessed by any function. They are also known as global
variables and default value is zero. Variables declared outside every function are
external variables. These variables are active and alive throughout the entire program.
Program
int sum = 60 ;
void print()
{
extern int sum ;
printf("nSum : %d",sum);
}
void main()
{
extern int sum ;
printf("nSum : %d",sum);
display();
}
Output
25. 25
Sum : 60
Sum : 60
Explanation
If variable sum is defined outside the source code , then declaration using extern keyword is
required. The display function uses the extern keyword.
26. 26
THE C PREPROCESSOR
It is a program that processes the source code before it process by compiler. The C
Preprocessor is not part of the compiler, but is a separate step in the compilation process. In
simplistic terms, a C Preprocessor is just a text substitution tool. We'll refer to the C
Preprocessor as the CPP. It operates under the control of command lines or directives. All
preprocessor lines begin with #.
It is placed before the main source program. If any directives are in the program the
actions are taken first and the main source program taken over the compiler next.
The pre-processor is the computer program that processes the source program written in c
language before compilation.
it contains a collection of special statements called directives or pre-processor.
It is placed before the main () function in c programs.
Advantages of pre-processor
1. Programs are easier to develop by using the pre-processor directives.
2. The c codes will be portable and easy to read.
The common preprocessor directives are,
Directive Function
#include Used to include a file.
#define Used to define symbolic constant
#ifdef Used to test macro definition
#else Used to specify alternative in #ifdef
#undef Used to undefined a macro.
#if Used a condition
#endif Used to specify the end of #if
27. 27
The Preprocessor directives are classified into
1) File Inclusion directives
2) Macro substitution directives
3) Compiler control directives
File Inclusion directives:
This is used to include an external file, which contains functions or some other macro
definitions to our source program, so we need not rewrite functions and macros in our source
program
Syntax
#include <filename.h>
#include "filename.h"
filename.h is the name of the file
ex: #include <stdio.h>
Compiler control directives:
The unconditional directives are:
#include - Inserts a particular header from another file
#define - Defines a preprocessor macro
o #define identifier string/integer
#undef - Undefines a preprocessor macro
The conditional directives are:
#ifdef - If this macro is defined
#ifndef - If this macro is not defined
#if - Test if a compile time condition is true
#else - The alternative for #if
28. 28
#elif - #else an #if in one statement
#endif - End preprocessor conditional
Other directives include:
# - Stringization, replaces a macro parameter with a string constant
## - Token merge, creates a single token from two adjacent ones
Some examples of the above:
#define MAX_ARRAY_LENGTH 20
Tells the CPP to replace instances of MAX_ARRAY_LENGTH with 20. Use #define for
constants to increase readability. Notice the absence of the semicolon(;).
#include <stdio.h>
#include "mystring.h"
Tells the CPP to get stdio.h from System Libraries and add the text to this file. The next line
tells CPP to get mystring.h from the local directory and add the text to the file.
Macro substitution directives:
i) simple macros
This is commonly used to define symbolic constants
#define A 10
macro substitutes ‘A’ with 10 in all occurrences in the source program.
ii) Argumented macros
The Argumented macros are used to define more complex and useful form of replacements in
the source program.
Syntax:
29. 29
#define identifier (v1 v2 v5….v4)string/integer
iii) Nested macros
The macros defined within another macro called nested macros.
Example:
#define A 5
This is a difference we must take note of.
#undef MEANING_OF_LIFE
#define MEANING_OF_LIFE 42
Tells the CPP to undefine MEANING_OF_LIFE and define it for 42.
#ifndef IROCK
#define IROCK "You wish!"
#endif
Tells the CPP to define IROCK only if IROCK isn't defined already.
#ifdef DEBUG
/* Your debugging statements here */
#endif
Tells the CPP to do the following statements if DEBUG is defined. This is useful if we pass
the -DDEBUG flag to gcc. This will define DEBUG, so we can turn debugging on and off on
the fly!
Parameterized Macros
One of the powerful functions of the C Pre Processor (CPP) is the ability to simulate
functions using parameterized macros. For example, we might have some code to square a
number:
30. 30
int square(int x)
{
return x * x;
}
We can instead rewrite this using a macro:
#define square(x) ((x) * (x))
Here is swap in action when using a macro:
#define swap(x, y) { int tmp = x; x = y; y = tmp }
Now we have swapping code that works. Why does this work? It's because the CPP just
simply replaces text. Wherever swap is called, the CPP will replace the macro call with the
defined text.
Example:
#define op L
main()
{
#ifdef L printf(“IBM”);
#else printf(“MS”);
#endif
}
31. 31
Unit V
PART A – 2 MARKS
1. What is structure?
A structure is a user defined data type which allows you to combine data items of
different kinds into a single unit. All the elements of a structure are stored at contiguous
memory locations. i.e., store heterogeneous data under unique name.
Keyword 'struct' is used to declare structure. The variables which are declared inside
the structure are called as 'members of structure'.
2. What is Union?
Union is user defined data type used to stored data under unique variable name at
single memory location. Union holds value for one data type which requires larger storage
among their members.
3. What are the differences between structure and union?
Structure Union
We can access all the members of
structure at anytime.
Only one member of union can be accessed at
anytime.
Memory is allocated for all variables.
Allocates memory for variable which variable
require more memory.
All members of structure can be
initialized
Only the first member of a union can be initialized.
'struct' keyword is used to declare
structure.
'union' keyword is used to declare union.
32. 32
4. What are advantages of union over structures
Union save memory space because the size of the union is equal to its largest sized
member. The size of the structure is the sum of the sizes of all structure members. So
Structure occupies a large space. Union are useful when there is a need to use only one of its
member at a time, But structure is used when there is a need to use all its members in a
program.
5. What is storage class ? List its types?
Storage classes
A storage class defines the scope (visibility) and life time of variables and/or
functions within a C Program.
There are following storage classes which can be used in a C Program
auto
register
static
extern
6. What is auto storage class?
auto is the default storage class for all local variables.
Ex: auto int age;
This variable are private (local) to the function in which they are declared. If automatic
variables are not initialized they will contain garbage.
7. What is static storage class?
static is the default storage class for global variables. Static variables are initialized
only once, when the program is compiled.
33. 33
Ex: static int count;
8. What is C Preprocessor?
It is a program that processes the source code before it process by compiler. The C
Preprocessor is not part of the compiler, but is a separate step in the compilation process. In
simplistic terms, a C Preprocessor is just a text substitution tool.
9. List out the various conditional directives.
1. #if
2. #ifdef
3. #ifdef
4. #elif
5. #elseif and
6. #endif
10. What are the different forms of macro substitution?
Simple macro
Argumented macro
Nested macros
11. What are the classification of preprocessor directives?
File Inclusion directives
Macro substitution directives
34. 34
PART-A (2 MARK)
1. Write any two different between structures and union.
2. List the common preprocessor directives.
3. What is the purpose of unions in C?
4. What is self-referential structure? Give an example.
5. Differentiate arrays from structures.
6. What are nested structures? Give an example.
PART –B
1. Explain about structures and unions suitable examples.
2. Draw a flowchart and write a C program to print student grade using structure
3. Write C program to read and write employee and their data of joining using Nested
structure.
4. Explain about structure declaration in C with suitable example.
5. Discuss about preprocessor facility in ‘C’.
6. Write a C program that gets and display the report of n students with their personal and
academic details using structures.
7. Write a C program to store the employee information details using structures and search
the particular employee information in employee information.
8. Explain the concept of storage classes with an example.
9. Write a C program to print the mark sheet for 10 students using structures.
10. Write the difference between structure and union.
11. Write a C program to create and print the student database with the following fields :
no,name,m1,m2,m3,m4,m5,total and average. If the student has failed in any of the
subjects, assign FAIL else based on the average, assign first class with distinction or,
first class or second class.
12. Create a employee database with 4 employees using nested structure : no, name and
address. Let the nested structure be salary with fields basic,hra,da,ta and cca. Display the
details of employees with salary >6000.
13. Define a data type for storing complex numbers and implement addition, subtraction,
multiplication operations for the defined type.
14. Create a payroll application using structure with the following details :
DA= 15% of basic
HRA= 20% of basic
TA=18% of basic
35. 35
Gross salary= basic+ HRA + DA + TA
Deduction= PF+ tax;
NetSalary=Gross Salary – Deduction
15. Write a C program using structure to print the details of book. Use array of structure