0% found this document useful (0 votes)
39 views2 pages

Unit 1 - Assignment B: Programming Assignment - Programming Exercises #2 (Chapter 2)

The document provides instructions for two C++ programming assignments. The first assignment asks students to write a program that produces specific output without screenshots. The second assignment asks students to write a program that prompts for a name, age, and favorite color, and then prints the input, submitting the code and a screenshot of the results. Students are to submit the source code for both assignments through a link by Sunday.

Uploaded by

Tim Williams
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Unit 1 - Assignment B: Programming Assignment - Programming Exercises #2 (Chapter 2)

The document provides instructions for two C++ programming assignments. The first assignment asks students to write a program that produces specific output without screenshots. The second assignment asks students to write a program that prompts for a name, age, and favorite color, and then prints the input, submitting the code and a screenshot of the results. Students are to submit the source code for both assignments through a link by Sunday.

Uploaded by

Tim Williams
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit 1 Assignment B

Programming Assignment - Programming Exercises #2 (Chapter 2)


Write a C++ program that produces the output shown (page 114). Submit the source
code only (no screen shots required) (15 points)

=START CODE=
#include <iostream>
#include <string>
using namespace std;
main()
{
cout << "CCCCCCCCC
++
++" << endl;
cout << "CC
++
++" << endl;
cout << "CC
++++++++++++++ ++++++++++++++" << endl;
cout << "CC
++++++++++++++ ++++++++++++++" << endl;
cout << "CC
++
++" << endl;
cout << "CCCCCCCCC
++
++" << endl;
}
=END CODE=
Programming Assignment (not in book)
Write and execute a C++ program that prompts you for your name, age and favorite
color and then prints them out after you have entered them in. Turn in the C++ code and
a screen snap of the results when you run the program. To get a screen shot on a PC, use
PrtSc (you may have to use the "fn" key on a laptop) and then open Microsoft Word and
paste the picture then submit the word document too. Other types of computers should
have similar capabilities. (15 points)

=START CODE=
#include <iostream>
#include <string>
using namespace std;
main ()
{
string txtStr;
cout << "What is your name?" << endl;
cin >> txtStr;
cout << "Hello " << txtStr << endl;
cout << "What is your age?" << endl;
cin >> txtStr;
cout << "Your age is " << txtStr << endl;
cout << "What is your favorite color?" << endl;
cin >> txtStr;
cout << "Your favorite color is " << txtStr << endl;
}
=END CODE=

Submit your assignment using the link above (due on Sunday of this unit; 30 points total).

You might also like