M
M
max volin2020-12-16 21:59:22
C++ / C#
max volin, 2020-12-16 21:59:22

And how to make me enter 2 words and the first one counts how many letters and the second word displays in a column?

#include <iostream>
using namespace std;
int main() {
  char s[50];
  int d = 0;
  cin >> s;
  while (s[d]) cout << s[d++] << endl;
  cout << "count: "<<  d;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuriy Vorobyov, 2020-12-16
@YuriyVorobyov1333

Here:

#include <iostream>
#include <string>

using namespace std;

int main()
{
  string str;

  cin >> str;

  for (char& c : str) {
    cout << c << endl;
  }

  cout << "count: "<< str.length() << endl;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question