SlideShare a Scribd company logo
1 of 11
Compiler design lab
ILIAS AHMED
ORACLE OCP
JAVA CERTIFIED
MICROSFT CERTIFED
RED HAT LINUX IN INDIA
How to A program to add 2 numbers on c compiler
#include<stdio.h>
nt addition(int, int);
nt main()
nt first, second, sum;
rintf("Enter first number:");
canf("%ld", &first);
rintf("Enter second number:");
canf("%ld", &second);
um = addition(first, second);
rintf("The result is : %ldn", sum);
eturn 0;
Design by ilias ahmed
int main()
{
FILE *fp;
char file[10];
printf("nEnter the filename: ");
scanf("%s", file);
fp=fopen(file,"r");
yyin=fp;
yylex();
printf("Total identifiers are: %dn", count);
Logic: We will write two C programs to find the sum of two integers and
display the addition result as output. ... numbers.
The %d used in scanf() and printf() functions is the format specifier which is
used for int data types in C programming
02# A program to check if comment or not
#include<stdio.h>
#include <conio.h>
int main()
{ char com[30] ;
int i=2 , a=0; printf("n Enter Comment:");
gets(com);
if(com[0]=='/')
{ if(com[1]=='/')
printf("n It is a comment");
else if (com[1]=='*')
{ for (i=2;i<=30;i++) { if(com[i]=='*'&&com[i+1]=='/')
{
printf("n It is a comment");
a=1;
break; }
else
continue;
if (a==0) printf("n It is not a comment"); }
else
printf("n It is not a comment"); }
else
printf("n It is not a comment");
getch();
}
INPUT & OUTPUT:
Input: Enter
comment: //hello
Output: It is a
comment Input:
Enter comment:
hello Output: It
is not a comment
Design by ilias ahmed
A program to check operator
==================================
===========================
#include<stdio.h>
#include<conio.h>
void main()
{
char s[5];
printf("n Enter any operator:");
gets(s);
switch(s[0])
{
case'>':
if(s[1]=='=')
printf("nGreater than or equal");
else printf("nGreater than");
break;
case'<':
if(s[1]=='=')
printf("n Less than or equal");
else printf("nLess than");
break;
case'=':
if(s[1]=='=')
printf("nEqual to");
else
printf("nAssignment");
break;
case'!':
if(s[1]=='=')
printf("nNot Equal");
else
printf("n Bit Not");
break;
case'&':
if(s[1]=='&')
printf("nLogicalAND");
case'&':
if(s[1]=='&')
printf("nLogicalAND");
else printf("n BitwiseAND");
break;
case'|':
if(s[1]=='|')
printf("nLogicalOR");
else
printf("nBitwiseOR");
break;
case'+':
printf("nAddition");
break;
case'-':
printf("nSubstraction");
break;
case'*':
printf("nMultiplication");
break;
case'/':
printf("nDivision");
break;
case'%':
printf("Modulus");
break;
default:
printf("n Not a operator");
}
getch();
}
Design by ilias ahmed

More Related Content

What's hot

Compiler Design lab manual for Computer Engineering .pdf
Compiler Design lab manual for Computer Engineering .pdfCompiler Design lab manual for Computer Engineering .pdf
Compiler Design lab manual for Computer Engineering .pdfkalpana Manudhane
 
Code generator
Code generatorCode generator
Code generatorTech_MX
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction Sarmad Ali
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generationIffat Anjum
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & RecoveryAkhil Kaushik
 
Arm assembly language programming
Arm assembly language programmingArm assembly language programming
Arm assembly language programmingv Kalairajan
 
Compiler Case Study - Design Patterns in C#
Compiler Case Study - Design Patterns in C#Compiler Case Study - Design Patterns in C#
Compiler Case Study - Design Patterns in C#CodeOps Technologies LLP
 
Principles of programming
Principles of programmingPrinciples of programming
Principles of programmingRob Paok
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 
Candidate elimination algorithm in ML Lab
Candidate elimination algorithm in ML LabCandidate elimination algorithm in ML Lab
Candidate elimination algorithm in ML LabVenkateswaraBabuRavi
 

What's hot (20)

Code optimization
Code optimizationCode optimization
Code optimization
 
Compiler Design lab manual for Computer Engineering .pdf
Compiler Design lab manual for Computer Engineering .pdfCompiler Design lab manual for Computer Engineering .pdf
Compiler Design lab manual for Computer Engineering .pdf
 
Code generator
Code generatorCode generator
Code generator
 
Compiler Design Unit 5
Compiler Design Unit 5Compiler Design Unit 5
Compiler Design Unit 5
 
Code generation
Code generationCode generation
Code generation
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
 
Intermediate code
Intermediate codeIntermediate code
Intermediate code
 
Compiler Design Unit 2
Compiler Design Unit 2Compiler Design Unit 2
Compiler Design Unit 2
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generation
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Arm assembly language programming
Arm assembly language programmingArm assembly language programming
Arm assembly language programming
 
Compiler Case Study - Design Patterns in C#
Compiler Case Study - Design Patterns in C#Compiler Case Study - Design Patterns in C#
Compiler Case Study - Design Patterns in C#
 
Principles of programming
Principles of programmingPrinciples of programming
Principles of programming
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
CSA PPT UNIT 1.pptx
CSA PPT UNIT 1.pptxCSA PPT UNIT 1.pptx
CSA PPT UNIT 1.pptx
 
Candidate elimination algorithm in ML Lab
Candidate elimination algorithm in ML LabCandidate elimination algorithm in ML Lab
Candidate elimination algorithm in ML Lab
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 

Similar to Compiler design lab

Similar to Compiler design lab (20)

C Programming
C ProgrammingC Programming
C Programming
 
C lab
C labC lab
C lab
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
comp1
comp1comp1
comp1
 
C coding#1
C   coding#1C   coding#1
C coding#1
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Progr3
Progr3Progr3
Progr3
 
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. AnsariBasic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 

More from ilias ahmed

We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...ilias ahmed
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorialilias ahmed
 
Signle assignmentforbciit
Signle assignmentforbciitSignle assignmentforbciit
Signle assignmentforbciitilias ahmed
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence ilias ahmed
 
Compiler designs presentation final
Compiler designs presentation  finalCompiler designs presentation  final
Compiler designs presentation finalilias ahmed
 
Compiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final finalCompiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final finalilias ahmed
 
Assmemble langauge for slideshare.net
Assmemble langauge for slideshare.netAssmemble langauge for slideshare.net
Assmemble langauge for slideshare.netilias ahmed
 
Phpfundamnetalfromtutplus
PhpfundamnetalfromtutplusPhpfundamnetalfromtutplus
Phpfundamnetalfromtutplusilias ahmed
 
Assignment complier design (GROUP1)
Assignment complier design (GROUP1)Assignment complier design (GROUP1)
Assignment complier design (GROUP1)ilias ahmed
 
Lisp programming
Lisp programmingLisp programming
Lisp programmingilias ahmed
 
Lispprograaming excercise
Lispprograaming excerciseLispprograaming excercise
Lispprograaming excerciseilias ahmed
 
Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)ilias ahmed
 
Data communications
Data communicationsData communications
Data communicationsilias ahmed
 
Microprocessor projec ts
Microprocessor projec tsMicroprocessor projec ts
Microprocessor projec tsilias ahmed
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshowilias ahmed
 

More from ilias ahmed (20)

We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorial
 
Signle assignmentforbciit
Signle assignmentforbciitSignle assignmentforbciit
Signle assignmentforbciit
 
Labreportofai
LabreportofaiLabreportofai
Labreportofai
 
Ailabreport
AilabreportAilabreport
Ailabreport
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence
 
Compiler designs presentation final
Compiler designs presentation  finalCompiler designs presentation  final
Compiler designs presentation final
 
Compiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final finalCompiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final final
 
Assmemble langauge for slideshare.net
Assmemble langauge for slideshare.netAssmemble langauge for slideshare.net
Assmemble langauge for slideshare.net
 
Phpfundamnetalfromtutplus
PhpfundamnetalfromtutplusPhpfundamnetalfromtutplus
Phpfundamnetalfromtutplus
 
Assignment complier design (GROUP1)
Assignment complier design (GROUP1)Assignment complier design (GROUP1)
Assignment complier design (GROUP1)
 
Lisp programming
Lisp programmingLisp programming
Lisp programming
 
Lispprograaming excercise
Lispprograaming excerciseLispprograaming excercise
Lispprograaming excercise
 
Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)
 
Event design
Event designEvent design
Event design
 
Vlan
VlanVlan
Vlan
 
Data communications
Data communicationsData communications
Data communications
 
Microprocessor projec ts
Microprocessor projec tsMicroprocessor projec ts
Microprocessor projec ts
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
Sql functions
Sql functionsSql functions
Sql functions
 

Recently uploaded

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
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
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Recently uploaded (20)

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
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...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
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
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Compiler design lab