homework4 - ECE 1574 Homework Set#4 Problem Solving with C...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 1574 Homework Set #4 Problem Solving with C++ Due date: 2/14/10 by 11:55PM This assignment is to be done individually Solve problems 1 through 5 during the lab session. Work the additional exercises later. 1. Ask the user to enter two characters. Then use the relational greater than operator to compare the two characters and output whether or not the first character entered is greater than or less than the second character entered #include <iostream> using std::cin; using std::cout; using std::endl; int main() { char character1; char character2; cout << "Please enter two characters" << endl; cin >> character1; cin >> character2; if (character1 > character2) cout << "The first character entered is greater than the second character entered." << endl; else if (character1 < character2) cout << "The second character entered is greater than the first character entered." << endl; else cout << "Both the characters entered are equal." << endl; return 0; } 2. Ask the user to enter a string then count and output the number of x's and 0's (zero and not character O) that occur in the string #include <iostream> #include <cstring> using std::cout; using std::endl; using std::cin; int main() {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
char allison[100]; cout << "Please enter a string" << endl; cin >> allison; int length = strlen(allison); int counter = 0; int zero = 0;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/15/2011 for the course ECE 1574 taught by Professor Rpbroadwater during the Spring '08 term at Virginia Tech.

Page1 / 6

homework4 - ECE 1574 Homework Set#4 Problem Solving with C...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online