SlideShare a Scribd company logo
1 of 4
Download to read offline
Enid M. Cruz-Colón
COMP 3010-030
HW 1: Compiler Toolchain
Problem 1
(a) The name of the executable program created by the compiler if the programmer does not
specify one is a.out.
(b) To compile a program and rename the executable file with a name other than the default
name, a.out, the command is:
g++ -o <new_name>.out <sourcecode_name>.cpp
Problem 2
The -Wall command line enables error warnings from the compiler when compiling your source
code.
The -c command line compiles a source code into an object file, not yet executable.
With the command g++ -o MyFirstProgram MyFirstSource.o we accomplish to change the
object code into machine code and store it in an executable program.
Problem 3
To change the program for it to greet the user with Hello, I inserted the following line, right
after the int number_of_pods, peas_per_pod, total_peas; line:
cout << “Hellon”;
To change the program for it to output Goodbye at the end, I inserted the following line, right
before the return 0; line:
cout << “Goodbyen”;
Problem 4
When replacing the “*” operator in the computation with a “/” and entering 0 for the number of
peas per pod, the compiler gives the following error: Floating point exception (core dumped). It
gives an error because the program is dividing the number of pods by peas per pod and you cannot
divide by 0.
Problem 5
When replacing the “/” operator in the computation with the “+” operator, the compiler does not
issue any errors, but the program gives a wrong answer.
Problem 6
(a) Error: Extra space between < and iostream.
Message: MyFirstSource.cpp:3:21: fatal error: iostream: No such file or directory
#include < iostream>
(b) Error: Omit < symbol in the #include directive.
Message: MyFirstSource.cpp:3:12: error: #include expects "FILENAME" or
<FILENAME>
#include iostream>
^
MyFirstSource.cpp: In function ‘int main()’:
MyFirstSource.cpp:8:3: error: ‘cout’ was not declared in this scope
cout << "Hellon";
^
MyFirstSource.cpp:11:3: error: ‘cin’ was not declared in this scope
cin >> number_of_pods;
^
(c) Error: Omit int from int main().
Message: MyFirstSource.cpp:5:10: warning: ISO C++ forbids declaration of ‘main’
with no type [-Wreturn-type]
main()
^
(d) Error: Misspell the word main.
Message: /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/crt1.o: In function
`_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
(e) Error: Omit (.
Message: MyFirstSource.cpp:5:9: error: expected initializer before ‘)’ token
int main)
^
Error: Omit both ( and ).
Message: MyFirstSource.cpp:6:1: warning: extended initializer lists only available
with -std=c++11 or -std=gnu++11
{
^
MyFirstSource.cpp:7:3: error: expected primary-expression before ‘int’
int number_of_pods, peas_per_pod, total_peas;
^
MyFirstSource.cpp:7:3: error: expected ‘}’ before ‘int’
MyFirstSource.cpp:7:3: error: expected ‘,’ or ‘;’ before ‘int’
MyFirstSource.cpp:8:3: error: ‘cout’ does not name a type
cout << "Hellon";
^
MyFirstSource.cpp:9:3: error: ‘cout’ does not name a type
cout << "Press return after entering a number.n";
^
MyFirstSource.cpp:10:3: error: ‘cout’ does not name a type
cout << "Enter the number of pods:n";
^
MyFirstSource.cpp:11:3: error: ‘cin’ does not name a type
cin >> number_of_pods;
^
MyFirstSource.cpp:12:3: error: ‘cout’ does not name a type
cout << "Enter the number of peas in a pod:n";
^
MyFirstSource.cpp:13:3: error: ‘cin’ does not name a type
cin >> peas_per_pod;
^
MyFirstSource.cpp:14:3: error: ‘total_peas’ does not name a type
total_peas = number_of_pods + peas_per_pod;
^
MyFirstSource.cpp:15:3: error: ‘cout’ does not name a type
cout << "If you have ";
^
MyFirstSource.cpp:16:3: error: ‘cout’ does not name a type
cout << number_of_pods;
^
MyFirstSource.cpp:17:3: error: ‘cout’ does not name a type
cout << " pea podsn";
^
MyFirstSource.cpp:18:3: error: ‘cout’ does not name a type
cout << "and ";
^
MyFirstSource.cpp:19:3: error: ‘cout’ does not name a type
cout << peas_per_pod;
^
MyFirstSource.cpp:20:3: error: ‘cout’ does not name a type
cout << " peas in each pod, thenn";
^
MyFirstSource.cpp:21:3: error: ‘cout’ does not name a type
cout << "you have ";
^
MyFirstSource.cpp:22:3: error: ‘cout’ does not name a type
cout << total_peas;
^
MyFirstSource.cpp:23:3: error: ‘cout’ does not name a type
cout << " peas in all the pods.n";
^
MyFirstSource.cpp:24:3: error: ‘cout’ does not name a type
cout << "Goodbyen";
^
MyFirstSource.cpp:25:3: error: expected unqualified-id before ‘return’
return 0;
^
MyFirstSource.cpp:26:1: error: expected declaration before ‘}’ token
}
^
(f) Error: Misspell cin.
Message: MyFirstSource.cpp: In function ‘int main()’:
MyFirstSource.cpp:11:3: error: ‘cn’ was not declared in this scope
cn >> number_of_pods;
^

More Related Content

What's hot

PyCon lightning talk on my Toro module for Tornado
PyCon lightning talk on my Toro module for TornadoPyCon lightning talk on my Toro module for Tornado
PyCon lightning talk on my Toro module for Tornadoemptysquare
 
ZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerAdam Englander
 
Debugging Your PHP Cake Application
Debugging Your PHP Cake ApplicationDebugging Your PHP Cake Application
Debugging Your PHP Cake ApplicationJose Diaz-Gonzalez
 
Python meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/OPython meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/OBuzzcapture
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris Ohk
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsP3 InfoTech Solutions Pvt. Ltd.
 
Of Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library designOf Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library designjspha
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main functionRumman Ansari
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generatorsdantleech
 
Stop Programming in JavaScript By Luck
Stop Programming in JavaScript By LuckStop Programming in JavaScript By Luck
Stop Programming in JavaScript By Lucksergioafp
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd StudyChris Ohk
 
clap: Command line argument parser for Pharo
clap: Command line argument parser for Pharoclap: Command line argument parser for Pharo
clap: Command line argument parser for PharoESUG
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 

What's hot (20)

PyCon lightning talk on my Toro module for Tornado
PyCon lightning talk on my Toro module for TornadoPyCon lightning talk on my Toro module for Tornado
PyCon lightning talk on my Toro module for Tornado
 
ZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async Primer
 
Debugging Your PHP Cake Application
Debugging Your PHP Cake ApplicationDebugging Your PHP Cake Application
Debugging Your PHP Cake Application
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Python meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/OPython meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/O
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
Cs project
Cs projectCs project
Cs project
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Of Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library designOf Harmony and Stinginess: Applicative, Monad, and iterative library design
Of Harmony and Stinginess: Applicative, Monad, and iterative library design
 
Intro to C++
Intro to C++Intro to C++
Intro to C++
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
 
Unix
UnixUnix
Unix
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
 
C++ file
C++ fileC++ file
C++ file
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
 
Stop Programming in JavaScript By Luck
Stop Programming in JavaScript By LuckStop Programming in JavaScript By Luck
Stop Programming in JavaScript By Luck
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
 
clap: Command line argument parser for Pharo
clap: Command line argument parser for Pharoclap: Command line argument parser for Pharo
clap: Command line argument parser for Pharo
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 

Similar to Compiler Errors in C++ Program

OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++cpjcollege
 
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...bhargavi804095
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cppNilesh Dalvi
 
C Programming- Harsh Sharma
C Programming- Harsh SharmaC Programming- Harsh Sharma
C Programming- Harsh SharmaHarsh Sharma
 
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFC BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFAbcdR5
 
A function definition num_digits with Cpp programnum_digits.cpp#.pdf
A function definition num_digits with Cpp programnum_digits.cpp#.pdfA function definition num_digits with Cpp programnum_digits.cpp#.pdf
A function definition num_digits with Cpp programnum_digits.cpp#.pdfanand1213
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.pptEPORI
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptxDineshDhuri4
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 studrohassanie
 
Chapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptChapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptDeepak Singh
 

Similar to Compiler Errors in C++ Program (20)

OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
lecture1 pf.pptx
lecture1 pf.pptxlecture1 pf.pptx
lecture1 pf.pptx
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Labsheet1stud
Labsheet1studLabsheet1stud
Labsheet1stud
 
C Programming- Harsh Sharma
C Programming- Harsh SharmaC Programming- Harsh Sharma
C Programming- Harsh Sharma
 
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFC BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
 
A function definition num_digits with Cpp programnum_digits.cpp#.pdf
A function definition num_digits with Cpp programnum_digits.cpp#.pdfA function definition num_digits with Cpp programnum_digits.cpp#.pdf
A function definition num_digits with Cpp programnum_digits.cpp#.pdf
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
C++basics
C++basicsC++basics
C++basics
 
C++basics
C++basicsC++basics
C++basics
 
c++basiccs.ppt
c++basiccs.pptc++basiccs.ppt
c++basiccs.ppt
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 stud
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
Chapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptChapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory Concept
 

More from enidcruz

Lab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and PointersLab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and Pointersenidcruz
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arraysenidcruz
 
Lab5: Functions 2
Lab5: Functions 2Lab5: Functions 2
Lab5: Functions 2enidcruz
 
Lab4: Functions
Lab4: FunctionsLab4: Functions
Lab4: Functionsenidcruz
 
Lab3: More Flow of Control
Lab3: More Flow of ControlLab3: More Flow of Control
Lab3: More Flow of Controlenidcruz
 
My First Source Code
My First Source CodeMy First Source Code
My First Source Codeenidcruz
 
Comp 3010 Syllabus
Comp 3010 SyllabusComp 3010 Syllabus
Comp 3010 Syllabusenidcruz
 
Foto-ensayo VIEQUES
Foto-ensayo VIEQUESFoto-ensayo VIEQUES
Foto-ensayo VIEQUESenidcruz
 

More from enidcruz (8)

Lab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and PointersLab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and Pointers
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
Lab5: Functions 2
Lab5: Functions 2Lab5: Functions 2
Lab5: Functions 2
 
Lab4: Functions
Lab4: FunctionsLab4: Functions
Lab4: Functions
 
Lab3: More Flow of Control
Lab3: More Flow of ControlLab3: More Flow of Control
Lab3: More Flow of Control
 
My First Source Code
My First Source CodeMy First Source Code
My First Source Code
 
Comp 3010 Syllabus
Comp 3010 SyllabusComp 3010 Syllabus
Comp 3010 Syllabus
 
Foto-ensayo VIEQUES
Foto-ensayo VIEQUESFoto-ensayo VIEQUES
Foto-ensayo VIEQUES
 

Recently uploaded

❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.Nitya salvi
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsSumit Kumar yadav
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptxRajatChauhan518211
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡anilsa9823
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000Sapana Sha
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINsankalpkumarsahoo174
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)PraveenaKalaiselvan1
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)Areesha Ahmad
 

Recently uploaded (20)

❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptx
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
The Philosophy of Science
The Philosophy of ScienceThe Philosophy of Science
The Philosophy of Science
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 

Compiler Errors in C++ Program

  • 1. Enid M. Cruz-Colón COMP 3010-030 HW 1: Compiler Toolchain Problem 1 (a) The name of the executable program created by the compiler if the programmer does not specify one is a.out. (b) To compile a program and rename the executable file with a name other than the default name, a.out, the command is: g++ -o <new_name>.out <sourcecode_name>.cpp Problem 2 The -Wall command line enables error warnings from the compiler when compiling your source code. The -c command line compiles a source code into an object file, not yet executable. With the command g++ -o MyFirstProgram MyFirstSource.o we accomplish to change the object code into machine code and store it in an executable program. Problem 3 To change the program for it to greet the user with Hello, I inserted the following line, right after the int number_of_pods, peas_per_pod, total_peas; line: cout << “Hellon”; To change the program for it to output Goodbye at the end, I inserted the following line, right before the return 0; line: cout << “Goodbyen”; Problem 4 When replacing the “*” operator in the computation with a “/” and entering 0 for the number of peas per pod, the compiler gives the following error: Floating point exception (core dumped). It gives an error because the program is dividing the number of pods by peas per pod and you cannot divide by 0. Problem 5 When replacing the “/” operator in the computation with the “+” operator, the compiler does not issue any errors, but the program gives a wrong answer. Problem 6 (a) Error: Extra space between < and iostream. Message: MyFirstSource.cpp:3:21: fatal error: iostream: No such file or directory #include < iostream> (b) Error: Omit < symbol in the #include directive.
  • 2. Message: MyFirstSource.cpp:3:12: error: #include expects "FILENAME" or <FILENAME> #include iostream> ^ MyFirstSource.cpp: In function ‘int main()’: MyFirstSource.cpp:8:3: error: ‘cout’ was not declared in this scope cout << "Hellon"; ^ MyFirstSource.cpp:11:3: error: ‘cin’ was not declared in this scope cin >> number_of_pods; ^ (c) Error: Omit int from int main(). Message: MyFirstSource.cpp:5:10: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] main() ^ (d) Error: Misspell the word main. Message: /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status (e) Error: Omit (. Message: MyFirstSource.cpp:5:9: error: expected initializer before ‘)’ token int main) ^ Error: Omit both ( and ). Message: MyFirstSource.cpp:6:1: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 { ^ MyFirstSource.cpp:7:3: error: expected primary-expression before ‘int’ int number_of_pods, peas_per_pod, total_peas; ^ MyFirstSource.cpp:7:3: error: expected ‘}’ before ‘int’ MyFirstSource.cpp:7:3: error: expected ‘,’ or ‘;’ before ‘int’ MyFirstSource.cpp:8:3: error: ‘cout’ does not name a type cout << "Hellon"; ^ MyFirstSource.cpp:9:3: error: ‘cout’ does not name a type cout << "Press return after entering a number.n"; ^ MyFirstSource.cpp:10:3: error: ‘cout’ does not name a type cout << "Enter the number of pods:n"; ^
  • 3. MyFirstSource.cpp:11:3: error: ‘cin’ does not name a type cin >> number_of_pods; ^ MyFirstSource.cpp:12:3: error: ‘cout’ does not name a type cout << "Enter the number of peas in a pod:n"; ^ MyFirstSource.cpp:13:3: error: ‘cin’ does not name a type cin >> peas_per_pod; ^ MyFirstSource.cpp:14:3: error: ‘total_peas’ does not name a type total_peas = number_of_pods + peas_per_pod; ^ MyFirstSource.cpp:15:3: error: ‘cout’ does not name a type cout << "If you have "; ^ MyFirstSource.cpp:16:3: error: ‘cout’ does not name a type cout << number_of_pods; ^ MyFirstSource.cpp:17:3: error: ‘cout’ does not name a type cout << " pea podsn"; ^ MyFirstSource.cpp:18:3: error: ‘cout’ does not name a type cout << "and "; ^ MyFirstSource.cpp:19:3: error: ‘cout’ does not name a type cout << peas_per_pod; ^ MyFirstSource.cpp:20:3: error: ‘cout’ does not name a type cout << " peas in each pod, thenn"; ^ MyFirstSource.cpp:21:3: error: ‘cout’ does not name a type cout << "you have "; ^ MyFirstSource.cpp:22:3: error: ‘cout’ does not name a type cout << total_peas; ^ MyFirstSource.cpp:23:3: error: ‘cout’ does not name a type cout << " peas in all the pods.n"; ^ MyFirstSource.cpp:24:3: error: ‘cout’ does not name a type cout << "Goodbyen"; ^ MyFirstSource.cpp:25:3: error: expected unqualified-id before ‘return’ return 0; ^ MyFirstSource.cpp:26:1: error: expected declaration before ‘}’ token } ^
  • 4. (f) Error: Misspell cin. Message: MyFirstSource.cpp: In function ‘int main()’: MyFirstSource.cpp:11:3: error: ‘cn’ was not declared in this scope cn >> number_of_pods; ^