It always comes out 0 and 0, I’m just trying to count the Gs and Cs (and non-Gs and Cs) in the string given by a user. I know this is a beginner problem, sorry about that 🙁
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x = 0
int y = 0
string s;
cout << "Enter a sequence" << endl;
cin >> s;
for (int i = 0; i > 100; i++)
if (s[i] == 'g' || s[i] == 'c')
x += 1;
else
y += 1;
cout << x << endl;
cout << y << endl;
}
You do realise
never runs, right?
You’re saying – “let
ibe0… as long asi > 100(lol – never) do something”.You probably meant
or you can use
std::count_if.