SlideShare a Scribd company logo
PAPER: INTRODUCTION PROGRAMMING LANGUAGE USING C
PAPER ID: 20105
PAPER CODE: BCA 105
DR. VARUN TIWARI
(ASSOCIATE PROFESSOR)
(DEPARTMENT OF COMPUTER SCIENCE)
BOSCO TECHNICAL TRAINING SOCIETY,
DON BOSCO TECHNICAL SCHOOL, OKHLA ROAD , NEW DELHI
BIT FIELD, COMMAND LINE
ARGUMENTS AND ENUM FUNCTION
OBJECTIVES
IN THIS CHAPTER YOU WILL LEARN:
1. TO UNDERSTAND ABOUT BIT FIELD IN C.
2. TO LEARN ABOUT COMMAND LINE ARGUMENTS IN C.
3. TO LEARN ABOUT ENUM IN C.
BIT FIELD: IN C PROGRAMMING BIT FIELD IS A DATA STRUCTURE THAT IS USED TO ALLOCATE MEMORY OF
UNION AND STRUCTURE IN BITS FORM. IT IS USED TO UTILIZE COMPUTER MEMORY IN EFFICIENT MANNER
IN C LANGUAGE. WE CAN SPECIFY SIZE (IN BITS) OF STRUCTURE AND UNION MEMBERS.
A BIT FIELD IS SIMPLY A DATA STRUCTURE THAT HELPS THE USER TO ALLOCATE MEMORY TO STRUCTURES
AND UNIONS.
• USE OF BIT FIELD
• BIT FIELD DECLARATION
• BIT FIELDS WORKING
SYNTAX: DATATYPE VARIABLE NAME : SIZE IN BITS;
Example of Bit Field:
#include <stdio.h> struct emp {
int a; int b; float c; } e1;
struct cust{ int a:1; int b:1; // float c:3; float p; }c1;
union teacher { int a:1; int b:2; //float c; }t1;
void main( ) {
clrscr();
printf( "size of structure is= %dn", sizeof(e1));
printf( "size of structure is= %dn", sizeof(c1));
printf("size of union is = %dn",sizeof(t1));
getch();
}
ENUM IN C: THE FULL FORM OF ENUM IS ENUMERATED TYPE. IT IS A USER-DEFINED DATA TYPE THAT
CONSISTS OF INTEGRAL CONSTANT. IT IS USED TO PROVIDE MEANINGFUL NAMES TO THESE CONSTANT.
WITH THE HELP OF ENUM C MAKES THE PROGRAM EASY TO UNDERSTAND AND MAINTAIN.
SYNTAX: ENUM ENUMNAME{INTEGER_CONST1, INTEGER_CONST2,.....INTEGTER_CONSTN};
enum month{jan,feb,march,april,may,june,july,august,september,october,november,december};
void main()
{
printf(“n value of march = %d”,march);
getch();
}
COMMAND LINE ARGUMENTS: SUPPOSE IF YOU PASS ANY ARGUMENTS IN MAIN FUNCTION IN C. THIS
TYPES OF ARGUMENTS ARE CALLED COMMAND LINE ARGUMENTS.
THE COMMAND LINE ARGUMENTS ARE USED TWO ARGUMENTS UNDER THE MAIN() FUNCTION
1. ARGC REFERS TO THE NUMBER OF ARGUMENTS PASSED,
2. ARGV[] IS A POINTER ARRAY WHICH POINTS TO EACH ARGUMENT PASSED TO THE PROGRAM.
#include<stdio.h> #include<conio.h>
int main( int argc, char *argv[] ) { int i,sum=0,a[5];
clrscr(); argc=5; for(i=0;i<argc;i++) {
printf("n enter any value-:");
scanf("%d",&argv[i]);
printf("n value is = %d",argv[i]);
a[i]=argv[i];
printf("n sum of given array");
sum+=a[i];
printf("n sum of array values-: %d",sum); }
getch(); }
THANK YOU
Ad

More Related Content

Similar to Bit field enum and command line arguments (20)

introductiontocprogramming-130719083552-phpapp01.ppt
introductiontocprogramming-130719083552-phpapp01.pptintroductiontocprogramming-130719083552-phpapp01.ppt
introductiontocprogramming-130719083552-phpapp01.ppt
RutviBaraiya
 
C Language_PPS_3110003_unit 8ClassPPT.ppt
C Language_PPS_3110003_unit 8ClassPPT.pptC Language_PPS_3110003_unit 8ClassPPT.ppt
C Language_PPS_3110003_unit 8ClassPPT.ppt
NikeshaPatel1
 
Chapter 8 Structure Part 2 (1).pptx
Chapter 8 Structure Part 2 (1).pptxChapter 8 Structure Part 2 (1).pptx
Chapter 8 Structure Part 2 (1).pptx
Abhishekkumarsingh630054
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
ABHISHEK fulwadhwa
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
Sowmya Jyothi
 
structured Programming Unit-2-Basic-Elements-of-C.pptx
structured Programming Unit-2-Basic-Elements-of-C.pptxstructured Programming Unit-2-Basic-Elements-of-C.pptx
structured Programming Unit-2-Basic-Elements-of-C.pptx
SuryaBasnet1
 
Unit3 overview of_c_programming
Unit3 overview of_c_programmingUnit3 overview of_c_programming
Unit3 overview of_c_programming
Capuchino HuiNing
 
C Structure and Union in C
C Structure and Union in CC Structure and Union in C
C Structure and Union in C
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Programming C Part 01
Programming C Part 01 Programming C Part 01
Programming C Part 01
Raselmondalmehedi
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
UNIT IC programming notes university file
UNIT IC programming notes university fileUNIT IC programming notes university file
UNIT IC programming notes university file
ANISHYAPIT
 
IT LAB Presentation (Aditya Sharma 23EEACS005).pptx
IT LAB Presentation (Aditya Sharma 23EEACS005).pptxIT LAB Presentation (Aditya Sharma 23EEACS005).pptx
IT LAB Presentation (Aditya Sharma 23EEACS005).pptx
chabriislive
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
Dr.M.Karthika parthasarathy
 
Fundamentals of c language
Fundamentals of c languageFundamentals of c language
Fundamentals of c language
AkshhayPatel
 
C-Programming Fundamentals of C (1).ppt
C-Programming  Fundamentals of C (1).pptC-Programming  Fundamentals of C (1).ppt
C-Programming Fundamentals of C (1).ppt
ssuserc13e6a
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
Mehul Desai
 
Introduction to ‘C’ Language
Introduction to ‘C’ LanguageIntroduction to ‘C’ Language
Introduction to ‘C’ Language
Thesis Scientist Private Limited
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
Dr. SURBHI SAROHA
 
introductiontocprogramming-130719083552-phpapp01.ppt
introductiontocprogramming-130719083552-phpapp01.pptintroductiontocprogramming-130719083552-phpapp01.ppt
introductiontocprogramming-130719083552-phpapp01.ppt
RutviBaraiya
 
C Language_PPS_3110003_unit 8ClassPPT.ppt
C Language_PPS_3110003_unit 8ClassPPT.pptC Language_PPS_3110003_unit 8ClassPPT.ppt
C Language_PPS_3110003_unit 8ClassPPT.ppt
NikeshaPatel1
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
Sowmya Jyothi
 
structured Programming Unit-2-Basic-Elements-of-C.pptx
structured Programming Unit-2-Basic-Elements-of-C.pptxstructured Programming Unit-2-Basic-Elements-of-C.pptx
structured Programming Unit-2-Basic-Elements-of-C.pptx
SuryaBasnet1
 
Unit3 overview of_c_programming
Unit3 overview of_c_programmingUnit3 overview of_c_programming
Unit3 overview of_c_programming
Capuchino HuiNing
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
UNIT IC programming notes university file
UNIT IC programming notes university fileUNIT IC programming notes university file
UNIT IC programming notes university file
ANISHYAPIT
 
IT LAB Presentation (Aditya Sharma 23EEACS005).pptx
IT LAB Presentation (Aditya Sharma 23EEACS005).pptxIT LAB Presentation (Aditya Sharma 23EEACS005).pptx
IT LAB Presentation (Aditya Sharma 23EEACS005).pptx
chabriislive
 
Fundamentals of c language
Fundamentals of c languageFundamentals of c language
Fundamentals of c language
AkshhayPatel
 
C-Programming Fundamentals of C (1).ppt
C-Programming  Fundamentals of C (1).pptC-Programming  Fundamentals of C (1).ppt
C-Programming Fundamentals of C (1).ppt
ssuserc13e6a
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
Mehul Desai
 

More from Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi) (20)

String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Preprocessor Directive in C
Preprocessor Directive in CPreprocessor Directive in C
Preprocessor Directive in C
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Pointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory AllocationPointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory Allocation
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Array in C
Array in CArray in C
Array in C
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C storage class
C storage classC storage class
C storage class
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C Operators
C OperatorsC Operators
C Operators
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
C programming Basics
C programming BasicsC programming Basics
C programming Basics
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Software Development Skills and SDLC
Software Development Skills and SDLCSoftware Development Skills and SDLC
Software Development Skills and SDLC
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Mobile commerce
Mobile commerceMobile commerce
Mobile commerce
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
E commerce application
E commerce applicationE commerce application
E commerce application
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Data normalization
Data normalizationData normalization
Data normalization
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Security issue in e commerce
Security issue in e commerceSecurity issue in e commerce
Security issue in e commerce
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Database connectivity with data reader by varun tiwari
Database connectivity with data reader by varun tiwariDatabase connectivity with data reader by varun tiwari
Database connectivity with data reader by varun tiwari
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Ado vs ado.net by varun tiwari
Ado vs ado.net by varun tiwariAdo vs ado.net by varun tiwari
Ado vs ado.net by varun tiwari
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Ad

Recently uploaded (20)

Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdfAPM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
Association for Project Management
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Ad

Bit field enum and command line arguments

  • 1. PAPER: INTRODUCTION PROGRAMMING LANGUAGE USING C PAPER ID: 20105 PAPER CODE: BCA 105 DR. VARUN TIWARI (ASSOCIATE PROFESSOR) (DEPARTMENT OF COMPUTER SCIENCE) BOSCO TECHNICAL TRAINING SOCIETY, DON BOSCO TECHNICAL SCHOOL, OKHLA ROAD , NEW DELHI
  • 2. BIT FIELD, COMMAND LINE ARGUMENTS AND ENUM FUNCTION
  • 3. OBJECTIVES IN THIS CHAPTER YOU WILL LEARN: 1. TO UNDERSTAND ABOUT BIT FIELD IN C. 2. TO LEARN ABOUT COMMAND LINE ARGUMENTS IN C. 3. TO LEARN ABOUT ENUM IN C.
  • 4. BIT FIELD: IN C PROGRAMMING BIT FIELD IS A DATA STRUCTURE THAT IS USED TO ALLOCATE MEMORY OF UNION AND STRUCTURE IN BITS FORM. IT IS USED TO UTILIZE COMPUTER MEMORY IN EFFICIENT MANNER IN C LANGUAGE. WE CAN SPECIFY SIZE (IN BITS) OF STRUCTURE AND UNION MEMBERS. A BIT FIELD IS SIMPLY A DATA STRUCTURE THAT HELPS THE USER TO ALLOCATE MEMORY TO STRUCTURES AND UNIONS. • USE OF BIT FIELD • BIT FIELD DECLARATION • BIT FIELDS WORKING SYNTAX: DATATYPE VARIABLE NAME : SIZE IN BITS;
  • 5. Example of Bit Field: #include <stdio.h> struct emp { int a; int b; float c; } e1; struct cust{ int a:1; int b:1; // float c:3; float p; }c1; union teacher { int a:1; int b:2; //float c; }t1; void main( ) { clrscr(); printf( "size of structure is= %dn", sizeof(e1)); printf( "size of structure is= %dn", sizeof(c1)); printf("size of union is = %dn",sizeof(t1)); getch(); }
  • 6. ENUM IN C: THE FULL FORM OF ENUM IS ENUMERATED TYPE. IT IS A USER-DEFINED DATA TYPE THAT CONSISTS OF INTEGRAL CONSTANT. IT IS USED TO PROVIDE MEANINGFUL NAMES TO THESE CONSTANT. WITH THE HELP OF ENUM C MAKES THE PROGRAM EASY TO UNDERSTAND AND MAINTAIN. SYNTAX: ENUM ENUMNAME{INTEGER_CONST1, INTEGER_CONST2,.....INTEGTER_CONSTN}; enum month{jan,feb,march,april,may,june,july,august,september,october,november,december}; void main() { printf(“n value of march = %d”,march); getch(); }
  • 7. COMMAND LINE ARGUMENTS: SUPPOSE IF YOU PASS ANY ARGUMENTS IN MAIN FUNCTION IN C. THIS TYPES OF ARGUMENTS ARE CALLED COMMAND LINE ARGUMENTS. THE COMMAND LINE ARGUMENTS ARE USED TWO ARGUMENTS UNDER THE MAIN() FUNCTION 1. ARGC REFERS TO THE NUMBER OF ARGUMENTS PASSED, 2. ARGV[] IS A POINTER ARRAY WHICH POINTS TO EACH ARGUMENT PASSED TO THE PROGRAM.
  • 8. #include<stdio.h> #include<conio.h> int main( int argc, char *argv[] ) { int i,sum=0,a[5]; clrscr(); argc=5; for(i=0;i<argc;i++) { printf("n enter any value-:"); scanf("%d",&argv[i]); printf("n value is = %d",argv[i]); a[i]=argv[i]; printf("n sum of given array"); sum+=a[i]; printf("n sum of array values-: %d",sum); } getch(); }