SlideShare ist ein Scribd-Unternehmen logo
1 von 9
# and ## Operators in C
Stringizing operator (#)
• This operator causes the corresponding actual argument to be enclosed in double
quotation marks. The # operator, which is generally called the stringize operator,
turns the argument it precedes into a quoted string. For more on pre-processor
directives – refer this
Examples :
• The following preprocessor turns the line printf(mkstr(geeksforgeeks));into
printf(“geeksforgeeks”);
• // CPP program to illustrate (#) operator
• #include <stdio.h>
• #define mkstr(s) #s
• int main(void)
• {
• printf(mkstr(geeksforgeeks));
• return 0;
• }
• Output:
• geeksforgeeks
In this program, value of a is replaced
by macro.
• // CPP program to illustrate (#) operator
• #include <iostream>
• using namespace std;
• #define a 8.3297
• int main()
• {
• cout << "Value of a is " << a << endl;
• return 0;
• }
• Output:
• Value of a is 8.3297
This program finds out maximum out of two numbers
using macro
• // CPP program to illustrate (#) operator
• #include <iostream>
• using namespace std;
• #define MAX(i, j) (((i) > (j)) ? i : j)
• int main()
• {
• int a, b;
• a = 250;
• b = 25;
• cout << "The maximum is " << MAX(a, b) << endl;
• return 0;
• }
• Output:
•
The maximum is 250
Token-pasting operator (##)
• Allows tokens used as actual arguments to be
concatenated to form other tokens. It is often useful to
merge two tokens into one while expanding macros.
This is called token pasting or token concatenation. The
‘##’ pre-processing operator performs token pasting.
When a macro is expanded, the two tokens on either
side of each ‘##’ operator are combined into a single
token, which then replaces the ‘##’ and the two
original tokens in the macro expansion.
Examples :
• The preprocessor transforms printf(“%d”, concat(x, y));
into printf(“%d”, xy);
The preprocessor transforms printf(“%d”, concat(x, y));
into printf(“%d”, xy);
• // CPP program to illustrate (##) operator
• #include <stdio.h>
• #define concat(a, b) a##b
• int main(void)
• {
• int xy = 30;
• printf("%d", concat(x, y));
• return 0;
• }
• Output:
• 30
• Application: The ## provides a way to
concatenate actual arguments during macro
expansion.
• If a parameter in the replacement text is
adjacent to a ##, the parameter is replaced by
the actual argument, the ## and surrounding
white space are removed, and the result is re-
scanned.
# and ## Operators in C ?
• In this section we will see what are the Stringize operator(#) and
Token Pasting operator(##) in C. The Stringize operator is a
preprocessor operator. It sends commands to compiler to convert a
token into string. We use this operator at the macro definition.
• Using stringize operator we can convert some text into string
without using any quotes.
• Example
• #include<stdio.h>
• #define STR_PRINT(x) #x
• main()
• {
• printf(STR_PRINT(This is a string without double quotes));
• }
• Output
• This is a string without double quotes
• The Token Pasting operator is a preprocessor operator.
It sends commands to compiler to add or concatenate
two tokens into one string. We use this operator at the
macro definition.
• Example
• Live Demo
• #include<stdio.h>
• #define STR_CONCAT(x, y) x##y
• main()
• {
• printf("%d", STR_CONCAT(20, 50));
• }
• Output
• 2050

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Socket System Calls
Socket System CallsSocket System Calls
Socket System Calls
 
8253,8254
8253,8254 8253,8254
8253,8254
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
 
Macro Processor
Macro ProcessorMacro Processor
Macro Processor
 
Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...
Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...
Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...
 
Modes of 80386
Modes of 80386Modes of 80386
Modes of 80386
 
2.8 bluetooth ieee 802.15
2.8 bluetooth   ieee 802.152.8 bluetooth   ieee 802.15
2.8 bluetooth ieee 802.15
 
Interrupt
InterruptInterrupt
Interrupt
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
Double data rate (ddr)
Double data rate (ddr)Double data rate (ddr)
Double data rate (ddr)
 
Compiler design lab programs
Compiler design lab programs Compiler design lab programs
Compiler design lab programs
 
Tcp ip
Tcp ipTcp ip
Tcp ip
 
Risc and cisc
Risc and ciscRisc and cisc
Risc and cisc
 
Introduction to Bus | Address, Data, Control Bus
Introduction to Bus | Address, Data, Control BusIntroduction to Bus | Address, Data, Control Bus
Introduction to Bus | Address, Data, Control Bus
 
Network layer logical addressing
Network layer logical addressingNetwork layer logical addressing
Network layer logical addressing
 
COA-QUESTION-BANK.pdf
COA-QUESTION-BANK.pdfCOA-QUESTION-BANK.pdf
COA-QUESTION-BANK.pdf
 
Computer architecture the pentium architecture
Computer architecture the pentium architectureComputer architecture the pentium architecture
Computer architecture the pentium architecture
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
 
Memory & the fetch decode-execute cycle
Memory & the fetch decode-execute cycleMemory & the fetch decode-execute cycle
Memory & the fetch decode-execute cycle
 
System bus timing 8086
System bus timing 8086System bus timing 8086
System bus timing 8086
 

Ähnlich wie # And ## operators in c

05 -working_with_the_preproce
05  -working_with_the_preproce05  -working_with_the_preproce
05 -working_with_the_preproceHector Garzo
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and typesimtiazalijoono
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4MKalpanaDevi
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++LPU
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C ProgrammingShuvongkor Barman
 
Cse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingCse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingMd. Ashikur Rahman
 
Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 

Ähnlich wie # And ## operators in c (20)

05 -working_with_the_preproce
05  -working_with_the_preproce05  -working_with_the_preproce
05 -working_with_the_preproce
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Preprocessors
PreprocessorsPreprocessors
Preprocessors
 
Fucntions & Pointers in C
Fucntions & Pointers in CFucntions & Pointers in C
Fucntions & Pointers in C
 
Python_Functions_Unit1.pptx
Python_Functions_Unit1.pptxPython_Functions_Unit1.pptx
Python_Functions_Unit1.pptx
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
cp Module4(1)
cp Module4(1)cp Module4(1)
cp Module4(1)
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
Unit 5 Part 1 Macros
Unit 5 Part 1 MacrosUnit 5 Part 1 Macros
Unit 5 Part 1 Macros
 
Functions
FunctionsFunctions
Functions
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Cse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingCse115 lecture04introtoc programming
Cse115 lecture04introtoc programming
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Function in c program
Function in c programFunction in c program
Function in c program
 
PreProcessorDirective.ppt
PreProcessorDirective.pptPreProcessorDirective.ppt
PreProcessorDirective.ppt
 

Mehr von Dr. Prashant Vats

Financial fucntions in ms e xcel
Financial fucntions in ms e xcelFinancial fucntions in ms e xcel
Financial fucntions in ms e xcelDr. Prashant Vats
 
3. lookup functions in excel
3. lookup functions in excel3. lookup functions in excel
3. lookup functions in excelDr. Prashant Vats
 
2. date and time function in excel
2. date and time function in excel2. date and time function in excel
2. date and time function in excelDr. Prashant Vats
 
1. statistical functions in excel
1. statistical functions in excel1. statistical functions in excel
1. statistical functions in excelDr. Prashant Vats
 
3. subtotal function in excel
3. subtotal function in excel3. subtotal function in excel
3. subtotal function in excelDr. Prashant Vats
 
2. mathematical functions in excel
2. mathematical functions in excel2. mathematical functions in excel
2. mathematical functions in excelDr. Prashant Vats
 
RESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIARESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIADr. Prashant Vats
 
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An OverviewIndia: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An OverviewDr. Prashant Vats
 
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...Dr. Prashant Vats
 
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...Dr. Prashant Vats
 
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIAMETHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIADr. Prashant Vats
 
Computer Software and Related IPR Issues
Computer Software and Related IPR Issues Computer Software and Related IPR Issues
Computer Software and Related IPR Issues Dr. Prashant Vats
 
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000Dr. Prashant Vats
 
Trademark Issues in cyberspace
Trademark Issues in cyberspace Trademark Issues in cyberspace
Trademark Issues in cyberspace Dr. Prashant Vats
 
Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)Dr. Prashant Vats
 
How to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright actHow to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright actDr. Prashant Vats
 
International Treaties for protection of IPR
International Treaties for protection of IPRInternational Treaties for protection of IPR
International Treaties for protection of IPRDr. Prashant Vats
 

Mehr von Dr. Prashant Vats (20)

Multiplexers
MultiplexersMultiplexers
Multiplexers
 
C lab programs
C lab programsC lab programs
C lab programs
 
Financial fucntions in ms e xcel
Financial fucntions in ms e xcelFinancial fucntions in ms e xcel
Financial fucntions in ms e xcel
 
4. text functions in excel
4. text functions in excel4. text functions in excel
4. text functions in excel
 
3. lookup functions in excel
3. lookup functions in excel3. lookup functions in excel
3. lookup functions in excel
 
2. date and time function in excel
2. date and time function in excel2. date and time function in excel
2. date and time function in excel
 
1. statistical functions in excel
1. statistical functions in excel1. statistical functions in excel
1. statistical functions in excel
 
3. subtotal function in excel
3. subtotal function in excel3. subtotal function in excel
3. subtotal function in excel
 
2. mathematical functions in excel
2. mathematical functions in excel2. mathematical functions in excel
2. mathematical functions in excel
 
RESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIARESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIA
 
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An OverviewIndia: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
 
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
 
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
 
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIAMETHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
 
Computer Software and Related IPR Issues
Computer Software and Related IPR Issues Computer Software and Related IPR Issues
Computer Software and Related IPR Issues
 
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
 
Trademark Issues in cyberspace
Trademark Issues in cyberspace Trademark Issues in cyberspace
Trademark Issues in cyberspace
 
Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)
 
How to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright actHow to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright act
 
International Treaties for protection of IPR
International Treaties for protection of IPRInternational Treaties for protection of IPR
International Treaties for protection of IPR
 

Kürzlich hochgeladen

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
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
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 

Kürzlich hochgeladen (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 

# And ## operators in c

  • 1. # and ## Operators in C
  • 2. Stringizing operator (#) • This operator causes the corresponding actual argument to be enclosed in double quotation marks. The # operator, which is generally called the stringize operator, turns the argument it precedes into a quoted string. For more on pre-processor directives – refer this Examples : • The following preprocessor turns the line printf(mkstr(geeksforgeeks));into printf(“geeksforgeeks”); • // CPP program to illustrate (#) operator • #include <stdio.h> • #define mkstr(s) #s • int main(void) • { • printf(mkstr(geeksforgeeks)); • return 0; • } • Output: • geeksforgeeks
  • 3. In this program, value of a is replaced by macro. • // CPP program to illustrate (#) operator • #include <iostream> • using namespace std; • #define a 8.3297 • int main() • { • cout << "Value of a is " << a << endl; • return 0; • } • Output: • Value of a is 8.3297
  • 4. This program finds out maximum out of two numbers using macro • // CPP program to illustrate (#) operator • #include <iostream> • using namespace std; • #define MAX(i, j) (((i) > (j)) ? i : j) • int main() • { • int a, b; • a = 250; • b = 25; • cout << "The maximum is " << MAX(a, b) << endl; • return 0; • } • Output: • The maximum is 250
  • 5. Token-pasting operator (##) • Allows tokens used as actual arguments to be concatenated to form other tokens. It is often useful to merge two tokens into one while expanding macros. This is called token pasting or token concatenation. The ‘##’ pre-processing operator performs token pasting. When a macro is expanded, the two tokens on either side of each ‘##’ operator are combined into a single token, which then replaces the ‘##’ and the two original tokens in the macro expansion. Examples : • The preprocessor transforms printf(“%d”, concat(x, y)); into printf(“%d”, xy);
  • 6. The preprocessor transforms printf(“%d”, concat(x, y)); into printf(“%d”, xy); • // CPP program to illustrate (##) operator • #include <stdio.h> • #define concat(a, b) a##b • int main(void) • { • int xy = 30; • printf("%d", concat(x, y)); • return 0; • } • Output: • 30
  • 7. • Application: The ## provides a way to concatenate actual arguments during macro expansion. • If a parameter in the replacement text is adjacent to a ##, the parameter is replaced by the actual argument, the ## and surrounding white space are removed, and the result is re- scanned.
  • 8. # and ## Operators in C ? • In this section we will see what are the Stringize operator(#) and Token Pasting operator(##) in C. The Stringize operator is a preprocessor operator. It sends commands to compiler to convert a token into string. We use this operator at the macro definition. • Using stringize operator we can convert some text into string without using any quotes. • Example • #include<stdio.h> • #define STR_PRINT(x) #x • main() • { • printf(STR_PRINT(This is a string without double quotes)); • } • Output • This is a string without double quotes
  • 9. • The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro definition. • Example • Live Demo • #include<stdio.h> • #define STR_CONCAT(x, y) x##y • main() • { • printf("%d", STR_CONCAT(20, 50)); • } • Output • 2050