Exercise 3. Use the program shell below to implement a program called SumDigits. When completed, program SumDigits prompts for and reads a one-digit number, then adds the numbers from zero to the number, inclusive, and prints the sum.
Exercise 3. Use the program shell below to implement a program called SumDigits. When completed, program SumDigits prompts for and reads a one-digit number, then adds the numbers from zero to the number, inclusive, and prints the sum.
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
Related questions
Question
Can anyone help me with these coding questions
![Exercise 3.
Use the program shell below to implement a program called SumDigits. When completed, program
SumDigits prompts for and reads a one-digit number, then adds the numbers from zero to the number,
inclusive, and prints the sum.
// Program SumDigits prompts for and reads a one-digit number.
// Values between 0 and the digit (inclusive) are summed.
#include <iostream>
using namespace std;
int main ()
// Loop-control variable
// Running sum
int counter;
int sum;
int digit;
cout <« "Enter a one-digit number; press return."
<< endl;
cin >> digit;
/* TO BE FILLED IN */
/* TO BE FILLED IN */
counter =
sum
while /* TO BE FILLED IN */
{
/*
TO BE FILLED IN */
cout << "Sum of digits between 0 and "
« digit << " is "
<< sum
<< endl;
return 0;
3 Event-controlled Loops
Use program shell CountUC for exercises 4 and 5.
// Program CountUC counts the number of uppercase letters
// on a line.
tinclude <iostream>
using namespace std;
int main ()
{
char letter;
int letterCt;
/* TO BE FILLED IN */
return 0;
}
Exercise 4.
Fill in the body of program CountUC so that the number of uppercase letters on a line of input is printed.
Run your program with the following input and show the result.
(Hint: 1. Remember that the ASCII code of letters are in alphabetic order, so an uppercase letter must
satisfy letter>='A' && letter<='Z'.
2. You can use cin.get(letter) to get each character in the line and exit the loop when it's '\n'.)
Input
AbbaDabbaD00
Output
Exercise 5.
Change program CountUC from Exercise 4 so that the counting stops if the input line contains a digit.
Run your program with the following data and show the results.
Output
Input
ABBAIDABBA2D00](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3f6c81c7-9a41-4014-8916-60df888d5014%2F0b4f6e02-bacc-4b64-82dc-14652bc3445a%2Fot27s8h_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Exercise 3.
Use the program shell below to implement a program called SumDigits. When completed, program
SumDigits prompts for and reads a one-digit number, then adds the numbers from zero to the number,
inclusive, and prints the sum.
// Program SumDigits prompts for and reads a one-digit number.
// Values between 0 and the digit (inclusive) are summed.
#include <iostream>
using namespace std;
int main ()
// Loop-control variable
// Running sum
int counter;
int sum;
int digit;
cout <« "Enter a one-digit number; press return."
<< endl;
cin >> digit;
/* TO BE FILLED IN */
/* TO BE FILLED IN */
counter =
sum
while /* TO BE FILLED IN */
{
/*
TO BE FILLED IN */
cout << "Sum of digits between 0 and "
« digit << " is "
<< sum
<< endl;
return 0;
3 Event-controlled Loops
Use program shell CountUC for exercises 4 and 5.
// Program CountUC counts the number of uppercase letters
// on a line.
tinclude <iostream>
using namespace std;
int main ()
{
char letter;
int letterCt;
/* TO BE FILLED IN */
return 0;
}
Exercise 4.
Fill in the body of program CountUC so that the number of uppercase letters on a line of input is printed.
Run your program with the following input and show the result.
(Hint: 1. Remember that the ASCII code of letters are in alphabetic order, so an uppercase letter must
satisfy letter>='A' && letter<='Z'.
2. You can use cin.get(letter) to get each character in the line and exit the loop when it's '\n'.)
Input
AbbaDabbaD00
Output
Exercise 5.
Change program CountUC from Exercise 4 so that the counting stops if the input line contains a digit.
Run your program with the following data and show the results.
Output
Input
ABBAIDABBA2D00
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 6 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education