Programming Worksheet
Programming Worksheet
Programming Worksheet
2. #include <iostream>
3. using namespace std;
4.
5. int main()
6. {
7. int firstNumber, secondNumber;
8. int sum, product;
9.
10. // Ask the user to enter two integers
11. cout << "Enter the first integer: ";
12. cin >> firstNumber;
13.
14. cout << "Enter the second integer: ";
15. cin >> secondNumber;
16.
17. // Calculate the sum and product of the two numbers
18. sum = firstNumber + secondNumber;
19. product = firstNumber * secondNumber;
20.
21. // Output the sum and product
22. cout << "The sum of " << firstNumber << " and " << secondNumber << " is: " << sum << endl;
23. cout << "The product of " << firstNumber << " and " << secondNumber << " is: " << product << endl;
24.
25. return 0;
26. }
2.
#include <iostream>
using namespace std;
int main() {
cout << "*********************************" << endl;
cout << "* *" << endl;
cout << "* C C C S S S S !! *" << endl;
cout << "* C C S S !! *" << endl;
cout << "* C S !! *" << endl;
cout << "* C S !! *" << endl;
cout << "* C S S S !! *" << endl;
cout << "* C S !! *" << endl;
cout << "* C C S !! *" << endl;
cout << "* C C C S S S !! *" << endl;
cout << "* *" << endl;
cout << "*********************************" << endl;
cout << "\n\nComputer Science is Cool Stuff!!!" << endl;
return 0;
}
3.
#include <iostream>
int main() {
char inputChar;
cout << "Enter a character: ";
cin >> inputChar;
cout << " " << inputChar << inputChar << inputChar << endl;
cout << inputChar << " " << inputChar << endl;
cout << inputChar << endl;
cout << inputChar << endl;
cout << inputChar << endl;
cout << inputChar << " " << inputChar << endl;
cout << " " << inputChar << inputChar << inputChar << endl;
return 0;
}
4.
#include <iostream>
using namespace std;
int main()
{
int numQuarters, numDimes, numNickels;
int totalCents;
// Ask the user to enter the number of quarters, dimes, and nickels
cout << "Enter the number of quarters: ";
cin >> numQuarters;
return 0;
}
5.
#include <iostream>
using namespace std;
int main()
{
double timeInSeconds, distance;
return 0;
}