// tally-alphabet
#include <iostream>
#include <vector>
using namespace std;
int main()
{
string text;
cout << "Enter text: ";
getline(cin, text);
// Could use 26 separate variables to count
// each letter of the alphabet. Instead, use
// a vector.
vector<int> tally(26);
// Loop through each char in text.
for(unsigned int i = 0; i < text.size(); i++)
{
char c = text.at(i);
c = toupper(c);
if(c >= 'A' && c <= 'Z') // or use isupper(c)
{
int pos = c - 'A'; // convert char to position
tally.at(pos)++; // increment that counter
}
}
// Print the tally
for(unsigned int i = 0; i < tally.size(); i++)
{
char c = 'A' + i;
cout << c << ": " << tally.at(i) << endl;
}
return 0;
}
#include <iostream>
using namespace std;
void frog(int x, int& q)
{
q = x * 3;
cout << x + 1 << endl;
}
void pig(int y, float z)
{
z = y * 0.2;
cout << z << endl;
}
int main()
{
int w = 9;
int z = 6;
frog(w, z);
pig(z, 1.1);
cout << w << endl;
cout << z << endl;
return 0;
}