SlideShare a Scribd company logo
Structures-in-C programming with examples
A structure is a collection of variables under a single name. These variables can be of
different types, and each has a name which is used to select it from the structure
Structure is a user-defined data type in C which allows you to combine different data
types to store in a new type
Structures helps to construct complex data types in more meaningful way.
Structure is some what similar to Array. The only different is that array is used to
store collection of similar data types while structure can store collection of any type
of data.
A structure is a user defined data type that groups logically related data items of
different data types into a single unit.
Suppose you want to store record of Student which consists of name,
address, roll number and age.
Structure is used to represent a record.
Suppose you want to store record of Book which consists of book
name, pages, price & author name.
All the elements of a structure are stored at contiguous memory locations.
A variable of structure type can store multiple data items of different data types
under the one name.
As the data of employee in company that is name, Employee ID, salary, address, phone
number is stored in structure data type.
We use ‘struct’ keyword to define a structure in C.
struct structureName
{
datatype variableName1;
datatype variableName2;
.
.
};
Syntax New Datatype name
Structure must end with
semicolon
Structure
Members
Suppose you want to store record of Student which consists of name,
address, roll number and age.
struct Student
{
char studName[15];
chat address[30];
int rollNumber;
int age;
};
Example
New Datatype name
Suppose you want to store record of Book which consists of book
name, pages, price & author name.
struct Book
{
char bookName[15];
chat author[30];
int pages;
float price;
};
Example
New Datatype name
Suppose you want to store record of Employee which consists of
name, ID, salary, address & dept.
struct Employee
{
int emp_id;
char empName[15];
chat address[30];
char dept[3]
float salary;
};
Example
New Datatype name

More Related Content

PPTX
Structure prespentation
PPTX
Structures in c language
PPTX
Structures in c language
PPT
2 lesson 2 object oriented programming in c++
PDF
Lk module4 structures
PPTX
DS_Lecture_05.1_05.2.pptxnjnshsgxdhdgcdhcbdhc
PDF
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
PPT
Lecture 04
Structure prespentation
Structures in c language
Structures in c language
2 lesson 2 object oriented programming in c++
Lk module4 structures
DS_Lecture_05.1_05.2.pptxnjnshsgxdhdgcdhcbdhc
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
Lecture 04

Similar to Structures-in-C programming with examples (20)

PDF
structure and union1.pdf
PPTX
C programing -Structure
PPTX
Introduction of structure (2)
DOCX
C UNIT-4 PREPARED BY M V BRAHMANANDA RE
PPTX
Programming in C
PDF
Chapter 13.1.9
PPT
Lecture number three Structures (1).ppt
PDF
fundamental programming languagech#2 (3).pdf
PPTX
Definition, Declaration of Structures in C.pptx
PPTX
Structures
PPTX
CPU : Structures And Unions
PPTX
C Structures and Unions
DOCX
Str
PDF
Structures in c++
PPTX
Structure in C++ in the name of the lord
PPT
Lecture 19 - Struct and Union
PPTX
Chapter4.pptx
PPTX
oop Lecture 1
DOCX
Structure and Typedef
DOCX
PPS 8.8.BASIC ALGORITHMS SEARCHING (LINEAR SEARCH, BINARY SEARCH ETC.)
structure and union1.pdf
C programing -Structure
Introduction of structure (2)
C UNIT-4 PREPARED BY M V BRAHMANANDA RE
Programming in C
Chapter 13.1.9
Lecture number three Structures (1).ppt
fundamental programming languagech#2 (3).pdf
Definition, Declaration of Structures in C.pptx
Structures
CPU : Structures And Unions
C Structures and Unions
Str
Structures in c++
Structure in C++ in the name of the lord
Lecture 19 - Struct and Union
Chapter4.pptx
oop Lecture 1
Structure and Typedef
PPS 8.8.BASIC ALGORITHMS SEARCHING (LINEAR SEARCH, BINARY SEARCH ETC.)
Ad

More from 10300PEDDIKISHOR (7)

PPT
c-Functions power point presentation on c functions
PPT
c-step-by-step-execution power point presentation
PPTX
file handling in c programming with file functions
PPT
Unity JDBC ICEIS ppt UnityJDBC ICEIS ppt
PPT
JDBC DriversPros and Cons of Each Driver
PPT
Java Database Connectivity Java Database
PDF
Every SQL Query must have: • SELECT clause: specifies columns to be retained ...
c-Functions power point presentation on c functions
c-step-by-step-execution power point presentation
file handling in c programming with file functions
Unity JDBC ICEIS ppt UnityJDBC ICEIS ppt
JDBC DriversPros and Cons of Each Driver
Java Database Connectivity Java Database
Every SQL Query must have: • SELECT clause: specifies columns to be retained ...
Ad

Recently uploaded (20)

PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Geodesy 1.pptx...............................................
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Welding lecture in detail for understanding
PPTX
Lecture Notes Electrical Wiring System Components
PPT
Project quality management in manufacturing
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Sustainable Sites - Green Building Construction
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Construction Project Organization Group 2.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Foundation to blockchain - A guide to Blockchain Tech
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Internet of Things (IOT) - A guide to understanding
Geodesy 1.pptx...............................................
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
CH1 Production IntroductoryConcepts.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Welding lecture in detail for understanding
Lecture Notes Electrical Wiring System Components
Project quality management in manufacturing
OOP with Java - Java Introduction (Basics)
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Sustainable Sites - Green Building Construction
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Construction Project Organization Group 2.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

Structures-in-C programming with examples

  • 2. A structure is a collection of variables under a single name. These variables can be of different types, and each has a name which is used to select it from the structure Structure is a user-defined data type in C which allows you to combine different data types to store in a new type Structures helps to construct complex data types in more meaningful way. Structure is some what similar to Array. The only different is that array is used to store collection of similar data types while structure can store collection of any type of data. A structure is a user defined data type that groups logically related data items of different data types into a single unit.
  • 3. Suppose you want to store record of Student which consists of name, address, roll number and age. Structure is used to represent a record. Suppose you want to store record of Book which consists of book name, pages, price & author name.
  • 4. All the elements of a structure are stored at contiguous memory locations. A variable of structure type can store multiple data items of different data types under the one name. As the data of employee in company that is name, Employee ID, salary, address, phone number is stored in structure data type.
  • 5. We use ‘struct’ keyword to define a structure in C. struct structureName { datatype variableName1; datatype variableName2; . . }; Syntax New Datatype name Structure must end with semicolon Structure Members
  • 6. Suppose you want to store record of Student which consists of name, address, roll number and age. struct Student { char studName[15]; chat address[30]; int rollNumber; int age; }; Example New Datatype name
  • 7. Suppose you want to store record of Book which consists of book name, pages, price & author name. struct Book { char bookName[15]; chat author[30]; int pages; float price; }; Example New Datatype name
  • 8. Suppose you want to store record of Employee which consists of name, ID, salary, address & dept. struct Employee { int emp_id; char empName[15]; chat address[30]; char dept[3] float salary; }; Example New Datatype name