The program in Figure 2 was written to find how many upper letters, numerals, operators, and total characters teth the array. However, the program contains syntax and logic errors. a) Identify the errors by drawing a circle around each of them. b) Correct the identified errors in (a). Attach the corrected program. c) Compile the program and improve it to achieve the desired output. Attach the output. d) Replace the while statement with the for statement. Attach the output. #include using namespace std; int main() { char text[10]=">_< KS06603 Engineering Programming is fun! >_<"; int i=0,Ch=0,0p=0,Uletters=0; while (text[i]!="r"); { if (text[i)>'a' && text[i]<='Z') Uletters+; else if (text[i]>='0' && text[i]<='9') Numdigits+; else if (text[ī]=='+||text[i]=='-') Op+; else if (text[i]==/||text[i]==") Op+; else if (textfi]=="%'||text[i]=='<"||text[i]==">'); Opt; else Ch+; } cout<<"Upper letters: "<

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
The program in Figure 2 was written to find how many upper letters, numerals,
operators, and total characters textn the
array. However, the program contains
syntax and logic errors.
a)
Identify the errors by drawing a circle around each of them.
b)
Correct the identified errors in (a). Attach the corrected program.
c)
Compile the program and improve it to achieve the desired output. Attach the output.
d)
Replace the while statement with the for statement. Attach the output.
#include <iostream>
using namespace std;
int main()
{
char text[10]=">_< KS06603 Engineering Programming is fun! >_<";
int i=0,Ch=0,0p=0,Uletters=0;
while (text[i]!='!");
{
if (text[i]>'a' && text[i]<='Z')
Uletters+;
else if (textfi)>='O' && text[i]<='9')
Numdigits+;
else if (text[i]=='+||text[i)=='-')
Opt;
else if (text[i]=='/||text[i]=="")
Opt;
else if (text[i]=="%'||text[i]=='<"||text[i]==">');
Opt;
else
Ch+;
}
cout<<"Upper letters: "<<Uletters<endl;
cout<<"Numerals: "<<Numdigits<<endl;
cout<<"Operators: "<<Op<<endl;
cout<<"Total Characters: "<< Uletters+ Numdigits+Op+Op+OP+Ch<<endl;
return 0;
}
Transcribed Image Text:The program in Figure 2 was written to find how many upper letters, numerals, operators, and total characters textn the array. However, the program contains syntax and logic errors. a) Identify the errors by drawing a circle around each of them. b) Correct the identified errors in (a). Attach the corrected program. c) Compile the program and improve it to achieve the desired output. Attach the output. d) Replace the while statement with the for statement. Attach the output. #include <iostream> using namespace std; int main() { char text[10]=">_< KS06603 Engineering Programming is fun! >_<"; int i=0,Ch=0,0p=0,Uletters=0; while (text[i]!='!"); { if (text[i]>'a' && text[i]<='Z') Uletters+; else if (textfi)>='O' && text[i]<='9') Numdigits+; else if (text[i]=='+||text[i)=='-') Opt; else if (text[i]=='/||text[i]=="") Opt; else if (text[i]=="%'||text[i]=='<"||text[i]==">'); Opt; else Ch+; } cout<<"Upper letters: "<<Uletters<endl; cout<<"Numerals: "<<Numdigits<<endl; cout<<"Operators: "<<Op<<endl; cout<<"Total Characters: "<< Uletters+ Numdigits+Op+Op+OP+Ch<<endl; return 0; }
Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY