1) What is the job of a compiler, and what is a compilation error? How does it differ from a run-time error? Provide an example for each kind of error.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
C++
I- Short Questions
In a text or word file, answer briefly the following questions:
1) What is the job of a compiler, and what is a compilation error? How does it differ from a run-time
error? Provide an example for each kind of error.
2) We want to define C++ variables to represent the following information in parts (a)-(d). For each one,
specify the most appropriate data type to use and write an example C++ statement that defines the
variable (choose any valid variable name) and assigns a valid value to it (i.e. choose a value that is
consistent with the data type and description of the variable).
Note: If more than one type can be used, you should choose the most appropriate one
(a) The number of students in a class
(b) The x-coordinate of a point
(c) The result of the logical expression (x<y)
(d) An English sentence
3) For a given numeric grade, the letter grade is obtained according to Table 1. The code below is
supposed to print the letter grade corresponding to the numeric grade grade (assume grade is a
predefined integer variable having a value between 0 and 100)
if (grade>-90)
cout<<'A'<<endl;
if(grade>-80)
Table 1
A grade 2 90
80 s grade << 90
cout<<'B'<<endl;
B
70 s grade < 80
60 s grade < 70
if (grade>=70)
cout<<'C'<<endl;
if (grade>-60)
D
cout<<'D'<<endl;
if (grade<60)
cout<<'F'<<endl;
F
grade < 60
(a) What is the problem with the code above? Give an example where we will get an incorrect
output.
(b) Propose two different ways to correct the code: write the complete corrected code for each
proposed solution (you can write the code as text; no cpp file required)
4) How many "Hi!"s will the following program print? Justify your answer.
for (int i=0; i<100; i++)(
for (int i-0; i<100; i++){
cout<<"Hi!"<<endl:
for (int i-0; i<10; 1++) {
for (int i-0; i<100; i++) {
cout<<"Hi!"<<endl;
for (int i-1; i<-10; i++) (
cout<<"Hi!"<<endl;
5) Explain what the following C++ statement does (note: it does multiple things):
bool C = 5==8:
Transcribed Image Text:I- Short Questions In a text or word file, answer briefly the following questions: 1) What is the job of a compiler, and what is a compilation error? How does it differ from a run-time error? Provide an example for each kind of error. 2) We want to define C++ variables to represent the following information in parts (a)-(d). For each one, specify the most appropriate data type to use and write an example C++ statement that defines the variable (choose any valid variable name) and assigns a valid value to it (i.e. choose a value that is consistent with the data type and description of the variable). Note: If more than one type can be used, you should choose the most appropriate one (a) The number of students in a class (b) The x-coordinate of a point (c) The result of the logical expression (x<y) (d) An English sentence 3) For a given numeric grade, the letter grade is obtained according to Table 1. The code below is supposed to print the letter grade corresponding to the numeric grade grade (assume grade is a predefined integer variable having a value between 0 and 100) if (grade>-90) cout<<'A'<<endl; if(grade>-80) Table 1 A grade 2 90 80 s grade << 90 cout<<'B'<<endl; B 70 s grade < 80 60 s grade < 70 if (grade>=70) cout<<'C'<<endl; if (grade>-60) D cout<<'D'<<endl; if (grade<60) cout<<'F'<<endl; F grade < 60 (a) What is the problem with the code above? Give an example where we will get an incorrect output. (b) Propose two different ways to correct the code: write the complete corrected code for each proposed solution (you can write the code as text; no cpp file required) 4) How many "Hi!"s will the following program print? Justify your answer. for (int i=0; i<100; i++)( for (int i-0; i<100; i++){ cout<<"Hi!"<<endl: for (int i-0; i<10; 1++) { for (int i-0; i<100; i++) { cout<<"Hi!"<<endl; for (int i-1; i<-10; i++) ( cout<<"Hi!"<<endl; 5) Explain what the following C++ statement does (note: it does multiple things): bool C = 5==8:
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education