Unit 1 - Assignment B: Programming Assignment - Programming Exercises #2 (Chapter 2)
Unit 1 - Assignment B: Programming Assignment - Programming Exercises #2 (Chapter 2)
=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).