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

More Related Content

Similar to Bit field enum and command line arguments

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
 
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
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
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Fundamentals of c language
Fundamentals of c languageFundamentals of c language
Fundamentals of c language
AkshhayPatel
 
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
SURBHI SAROHA
 
C language by Dr. D. R. Gholkar
C language by Dr. D. R. GholkarC language by Dr. D. R. Gholkar
C language by Dr. D. R. Gholkar
PRAVIN GHOLKAR
 
DECORATOR PATTERN IN WEB APPLICATION
DECORATOR PATTERN IN WEB APPLICATIONDECORATOR PATTERN IN WEB APPLICATION
DECORATOR PATTERN IN WEB APPLICATION
ijait
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Rohit Singh
 
6276830.ppt
6276830.ppt6276830.ppt
6276830.ppt
Shrinivas54
 
C programming.pdf
C programming.pdfC programming.pdf
C programming.pdf
JitendraYadav351971
 
Assistant robot through deep learning
Assistant robot through deep learning Assistant robot through deep learning
Assistant robot through deep learning
IJECEIAES
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Vivek Singh
 
C programming session 13
C programming session 13C programming session 13
C programming session 13
Vivek Singh
 
Structures
StructuresStructures
Structures
Mitali Chugh
 

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

Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
Unit3 overview of_c_programming
Unit3 overview of_c_programmingUnit3 overview of_c_programming
Unit3 overview of_c_programming
 
C Structure and Union in C
C Structure and Union in CC Structure and Union in C
C Structure and Union in C
 
Programming C Part 01
Programming C Part 01 Programming C Part 01
Programming C Part 01
 
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
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
 
Fundamentals of c language
Fundamentals of c languageFundamentals of c language
Fundamentals of c language
 
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
 
Introduction to ‘C’ Language
Introduction to ‘C’ LanguageIntroduction to ‘C’ Language
Introduction to ‘C’ Language
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
 
C language by Dr. D. R. Gholkar
C language by Dr. D. R. GholkarC language by Dr. D. R. Gholkar
C language by Dr. D. R. Gholkar
 
DECORATOR PATTERN IN WEB APPLICATION
DECORATOR PATTERN IN WEB APPLICATIONDECORATOR PATTERN IN WEB APPLICATION
DECORATOR PATTERN IN WEB APPLICATION
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)
 
6276830.ppt
6276830.ppt6276830.ppt
6276830.ppt
 
C programming.pdf
C programming.pdfC programming.pdf
C programming.pdf
 
Assistant robot through deep learning
Assistant robot through deep learning Assistant robot through deep learning
Assistant robot through deep learning
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
C programming session 13
C programming session 13C programming session 13
C programming session 13
 
Structures
StructuresStructures
Structures
 

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

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

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
 
Preprocessor Directive in C
Preprocessor Directive in CPreprocessor Directive in C
Preprocessor Directive in C
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
 
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
 
Array in C
Array in CArray in C
Array in C
 
C storage class
C storage classC storage class
C storage class
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
C Operators
C OperatorsC Operators
C Operators
 
C programming Basics
C programming BasicsC programming Basics
C programming Basics
 
Software Development Skills and SDLC
Software Development Skills and SDLCSoftware Development Skills and SDLC
Software Development Skills and SDLC
 
Mobile commerce
Mobile commerceMobile commerce
Mobile commerce
 
E commerce application
E commerce applicationE commerce application
E commerce application
 
Data normalization
Data normalizationData normalization
Data normalization
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Security issue in e commerce
Security issue in e commerceSecurity issue in e commerce
Security issue in e commerce
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
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
 
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
 

Recently uploaded

Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 

Recently uploaded (20)

Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 

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(); }