0
votes
# include <iostream>
# include <cmath>

using namespace std;

int main();
{

  string color, plural noun, celebrity;
  
  cout << "Enter a color: ";
  getline(cin, color);

  return 0;
}
1
was meant to put ' { ' and ' { ' on a different line to ' int main ' and ' return 0 'Thomas Halstead
Format code!. Remove ; after main(). Put , after pluralvik_78
I have removed the ; after main() but my latter part of the code wasThomas Halstead
cout << "Roses are {color}" << endl;Thomas Halstead
cout << "{plural noun} are blue" << endl;Thomas Halstead

1 Answers

0
votes

There are errors in your code. Firstly, have you included #include <string> and #include <iostream> directives. Moreover, your code is as follows:

    int main();{
       string color, plural noun, celebrity;
       cout<<"Enter a color: ";
       getline(cin, color);
       return 0;
    }

However, if you notice, you have placed a semicolon (;) after the int main function, which might be giving you an error. Also, as you were discussing in the comment section, declare plural noun as pluralNoun or plural_noun; never leave a space. I addition, a string is never called as cout<<"Roses are {color}"<<endl;, strings have to be called as:

    #include<iostream>
    #include <string>
    int main();{
       string color, pluralNoun, celebrity;
       cout << "Enter a color: ";
       getline(cin, color);
       cout << "Roses are " << color << endl;

       cout << "Enter a plural noun: ";
       getline(cin,pluralNoun);
       cout << pluralNoun << "are blue" << endl;
       return 0;
    }

The code above and your latter code; if executed in the same way as above will definitely not give you an error. Hope this helped you overcome the problem! :)