Q1. Consider the following C++ program which has some syntax mistakes. 1 #include 2 using namespace std 4 const int NUM1 = 5, NUM2; 6 int main () 7 { 8 int a; b; c; 9. char grade; 10 cout << "Enter two integers: "; cin << a << b; 11 12 13 14 cout « endl « "The numbers you entered are <« a « " and " << b << endl; 16 NUM = 10; c * 2 = NUM1 + NUM2 * b - a; 17 18 %3D 19 cout <« "c = " « c < endl; 20 21 = A; grade cout <« "Your grade is " « 'grade' << endl; 22 23 24 return 0; 25 } Identify and explain all the syntax errors. Then correct them. * Please provide line numbers in your answer. H H H1 2 222 2

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter2: Basic Elements Of C++
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
Q1.
Consider the following C++ program which has some syntax mistakes.
1 #include <iostream>
2 using namespace std
3
4 const int NUM1 = 5, NUM2;
5
6 int main ()
7
{
8
int a; b; c;
char grade;
11
cout << "Enter two integers: ";
12
cin << a << b;
13
14
cout <« endl « "The numbers you entered are
<« a « " and " << b << endl;
15
16
NUM = 10;
c * 2 = NUM1 + NUM2 * b - a;
cout << "c = " << c << endl;
17
18
19
20
grade = A;
cout <« "Your grade is " « 'grade' << endl;
21
22
23
24
return 0;
25 }
Identify and explain all the syntax errors. Then correct them.
* Please provide line numbers in your answer.
Q2. Explain the differences between Local Variable and Global Variable with your own
words? Provide your own C++ code that is suitable to illustrate both.
Q3. Two kinds of loops occur frequently in programming: counter-controlled loops and
sentinel-controlled loops.
Explain each kind of loop in terms of its implementation with your own examples.
N 345
Transcribed Image Text:Q1. Consider the following C++ program which has some syntax mistakes. 1 #include <iostream> 2 using namespace std 3 4 const int NUM1 = 5, NUM2; 5 6 int main () 7 { 8 int a; b; c; char grade; 11 cout << "Enter two integers: "; 12 cin << a << b; 13 14 cout <« endl « "The numbers you entered are <« a « " and " << b << endl; 15 16 NUM = 10; c * 2 = NUM1 + NUM2 * b - a; cout << "c = " << c << endl; 17 18 19 20 grade = A; cout <« "Your grade is " « 'grade' << endl; 21 22 23 24 return 0; 25 } Identify and explain all the syntax errors. Then correct them. * Please provide line numbers in your answer. Q2. Explain the differences between Local Variable and Global Variable with your own words? Provide your own C++ code that is suitable to illustrate both. Q3. Two kinds of loops occur frequently in programming: counter-controlled loops and sentinel-controlled loops. Explain each kind of loop in terms of its implementation with your own examples. N 345
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Variables
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning