Apr 30, 2020 at 8:01pm UTC
What am missing? I only get the message
#include <iostream>
#include <string>
#include <array>
using namespace std;
int main (void)
{
int index = 0;
string message = "hello all!";
for (index = 0; index < message.length(); index ++)
{
cout << message[index];
}
cout << endl;
}
Last edited on May 2, 2020 at 3:43am UTC
Apr 30, 2020 at 8:39pm UTC
I converted it, but it said the same thing as before that ISO C++ forbids comparison between pointer and integer
#include <iostream>
using namespace std;
int main(void)
{
float grade[10];
for(int i = 0; i < 10; ++i)
cin >> grade[i];
cout << "put in 10 grades\n";
if (grade >=90 && grade <= 100)
{
cout << "A\n";
}
else if (grade >= 80 && grade <= 89)
{
cout << "B\n";
}
else if (grade >= 70 && grade <= 79)
{
cout << "C\n";
}
else if (grade >= 60 && grade <= 69)
{
cout << "D\n";
}
else if (grade < 60 && grade >= 0)
{
cout << "F\n";
}
return(0);
}
Apr 30, 2020 at 8:56pm UTC
Not sure what happened but I finally got it.
#include <iostream>
using namespace std;
int main(void)
{
float grade[10];
float average;
cout << "put in 10 grades\n";
for(int i = 0; i < 10; ++i)
cin >> grade[i];
average = (grade[0]+grade[1]+grade[2]+grade[3]+grade[4]+grade[5]+grade[6]+grade[7]+grade[8]+grade[9])/10;
if (average >=90 && average <= 100)
{
cout << "A\n";
}
else if (average >= 80 && average <= 89)
{
cout << "B\n";
}
else if (average >= 70 && average <= 79)
{
cout << "C\n";
}
else if (average >= 60 && average <= 69)
{
cout << "D\n";
}
else if (average < 60 && average >= 0)
{
cout << "F\n";
}
return(0);
}
May 2, 2020 at 3:13am UTC
That makes sense, I had average evaluated after so then it worked.