SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Structure
Structures are user defined data types
It is a collection of heterogeneous data
It can have integer, float, double or character data in
it
We can also have array of structures
struct <<structname>>
{
members;
}element;
We can access element.members;
Example
struct Person
{
int id;
char name[5];
}P1;
P1.id = 1;
P1.name = “vasu”;
typedef statement
User Defined Data Types
The C language provides a facility called typedef for
creating synonyms for previously defined data type names.
For example, the declaration:
typedef int Length;
makes the name Length a synonym (or alias) for the data
type int.
typedef(contd.)
The data “type” name Length can now be used in
declarations in exactly the same way that the
data type int can be used:
Length a, b, len ;
Length numbers[10] ;
UNION
UNION
Union has members of different data types, but can
hold data of only one member at a time.
The different members share the same memory
location.
The total memory allocated to the union is equal to
the maximum size of the member.
EXAMPLE
#include <stdio.h>
union marks
{
    float percent;
    char grade;
};
int main ( )
{
    union marks student1;
    student1.percent = 98.5;
    printf( "Marks are %f   address is %16lun", student1.perc
ent, &student1.percent);
    student1.grade = 'A';
    printf( "Grade is %c address is %16lun", student1.grade, 
&student1.grade);
}
ENUM
ENUMERATED DATATYPE
Enumeration is a user-defined data type.  It is 
defined using the keyword enum and the syntax 
is: 
       enum tag_name {name_0, …, name_n} ; 
The tag_name is not used directly. The names in 
the braces are symbolic constants that take on 
integer values from zero through n. 
Enumerated(contd.)
As an example, the statement:
enum colors { red, yellow, green } ;
creates three constants.
red is assigned the value 0,
yellow is assigned 1 and
green is assigned 2.
Structure in c

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Structures
StructuresStructures
Structures
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
 
Strings in c
Strings in cStrings in c
Strings in c
 
Structure c
Structure cStructure c
Structure c
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structure
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
 
Structure in C language
Structure in C languageStructure in C language
Structure in C language
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
 
C Pointers
C PointersC Pointers
C Pointers
 
C programming - String
C programming - StringC programming - String
C programming - String
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 

Andere mochten auch (6)

Structures in c++
Structures in c++Structures in c++
Structures in c++
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 
Structure in C
Structure in CStructure in C
Structure in C
 
Structure in c
Structure in cStructure in c
Structure in c
 
Structure and Typedef
Structure and TypedefStructure and Typedef
Structure and Typedef
 
C Structures And Unions
C  Structures And  UnionsC  Structures And  Unions
C Structures And Unions
 

Ähnlich wie Structure in c

What is Non-primitive data type?
What is Non-primitive data type?What is Non-primitive data type?
What is Non-primitive data type?AnuragSrivastava272
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGEPRASANYA K
 
Str
StrStr
StrAcad
 
Structures
StructuresStructures
Structuresselvapon
 
Explain the importance of using the typedef keyword then write a C ++.docx
Explain the importance of using the typedef keyword then write a C ++.docxExplain the importance of using the typedef keyword then write a C ++.docx
Explain the importance of using the typedef keyword then write a C ++.docxjames876543264
 
Union from C and Data Strutures
Union from C and Data StruturesUnion from C and Data Strutures
Union from C and Data StruturesAcad
 
Unit_6StructureandUnionpptx__2023_01_04_16_48_56.pptx
Unit_6StructureandUnionpptx__2023_01_04_16_48_56.pptxUnit_6StructureandUnionpptx__2023_01_04_16_48_56.pptx
Unit_6StructureandUnionpptx__2023_01_04_16_48_56.pptxvekariyakashyap
 
DATA TYPES IN C Language.pptx
DATA TYPES IN C Language.pptxDATA TYPES IN C Language.pptx
DATA TYPES IN C Language.pptxkaransethi63
 
User Defined Datatypes in C++ (Union, enum, class)
User Defined Datatypes in C++  (Union, enum, class)User Defined Datatypes in C++  (Union, enum, class)
User Defined Datatypes in C++ (Union, enum, class)ChereLemma2
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structsSaad Sheikh
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Raj Naik
 
#Jai c presentation
#Jai c presentation#Jai c presentation
#Jai c presentationJAI BAMORIYA
 
Union
UnionUnion
UnionAcad
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxAmrutaNavale2
 
Structure prespentation
Structure prespentation Structure prespentation
Structure prespentation ashu awais
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 
Data Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn HubData Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn HubLearn Hub
 

Ähnlich wie Structure in c (20)

What is Non-primitive data type?
What is Non-primitive data type?What is Non-primitive data type?
What is Non-primitive data type?
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
 
Str
StrStr
Str
 
Structures
StructuresStructures
Structures
 
Explain the importance of using the typedef keyword then write a C ++.docx
Explain the importance of using the typedef keyword then write a C ++.docxExplain the importance of using the typedef keyword then write a C ++.docx
Explain the importance of using the typedef keyword then write a C ++.docx
 
Unions.pptx
Unions.pptxUnions.pptx
Unions.pptx
 
Union from C and Data Strutures
Union from C and Data StruturesUnion from C and Data Strutures
Union from C and Data Strutures
 
Unit_6StructureandUnionpptx__2023_01_04_16_48_56.pptx
Unit_6StructureandUnionpptx__2023_01_04_16_48_56.pptxUnit_6StructureandUnionpptx__2023_01_04_16_48_56.pptx
Unit_6StructureandUnionpptx__2023_01_04_16_48_56.pptx
 
DATA TYPES IN C Language.pptx
DATA TYPES IN C Language.pptxDATA TYPES IN C Language.pptx
DATA TYPES IN C Language.pptx
 
User Defined Datatypes in C++ (Union, enum, class)
User Defined Datatypes in C++  (Union, enum, class)User Defined Datatypes in C++  (Union, enum, class)
User Defined Datatypes in C++ (Union, enum, class)
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
 
Data types
Data typesData types
Data types
 
#Jai c presentation
#Jai c presentation#Jai c presentation
#Jai c presentation
 
Union
UnionUnion
Union
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
 
Structure prespentation
Structure prespentation Structure prespentation
Structure prespentation
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Data Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn HubData Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn Hub
 
17 structure-and-union
17 structure-and-union17 structure-and-union
17 structure-and-union
 

Mehr von Prabhu Govind (20)

Preprocessor in C
Preprocessor in CPreprocessor in C
Preprocessor in C
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
 
File in c
File in cFile in c
File in c
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Unions in c
Unions in cUnions in c
Unions in c
 
Array & string
Array & stringArray & string
Array & string
 
Recursive For S-Teacher
Recursive For S-TeacherRecursive For S-Teacher
Recursive For S-Teacher
 
User defined Functions in C
User defined Functions in CUser defined Functions in C
User defined Functions in C
 
Pre defined Functions in C
Pre defined Functions in CPre defined Functions in C
Pre defined Functions in C
 
Looping in C
Looping in CLooping in C
Looping in C
 
Branching in C
Branching in CBranching in C
Branching in C
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
Operators in C
Operators in COperators in C
Operators in C
 
Statements in C
Statements in CStatements in C
Statements in C
 
Data types in C
Data types in CData types in C
Data types in C
 
Constants in C
Constants in CConstants in C
Constants in C
 
Variables_c
Variables_cVariables_c
Variables_c
 
Tokens_C
Tokens_CTokens_C
Tokens_C
 
Computer basics
Computer basicsComputer basics
Computer basics
 
Computer fundamentals
Computer fundamentalsComputer fundamentals
Computer fundamentals
 

Kürzlich hochgeladen

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Kürzlich hochgeladen (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Structure in c