Browse Source

equal

master
DEW 11 months ago
parent
commit
7e325f634e
  1. 14
      equal.cpp
  2. 19
      forstr2.cpp

14
equal.cpp

@ -0,0 +1,14 @@
#include <iostream>
int main()
{
using namespace std;
int quizscores[10] = {20,20,20,20,20,19,20,18,20,20};
cout <<"Doing it right:\n";
int i;
for (i = 0;quizscores[i] == 20;i++)
cout <<"quiz "<<i << " is a 20\n";
cout <<"Doing it dangerous wrong:\n";
for (i = 0;quizscores[i] = 20;i++)
cout <<"quiz "<<i <<" is a 20\n";
return 0;
}

19
forstr2.cpp

@ -0,0 +1,19 @@
#include <iostream>
int main()
{
using namespace std;
cout << "Enter a word: ";
string word;
cin >> word;
char temp;
int i, j;
for (j = 0, i = word.size() - 1; j < i; --i, ++j)
{
temp = word[i];
word[i] = word[j];
word[j] = temp;
}
cout << word << "\nDone\n";
return 0;
}
Loading…
Cancel
Save