# include <iostream>
# include <cmath>
using namespace std;
int main();
{
string color, plural noun, celebrity;
cout << "Enter a color: ";
getline(cin, color);
return 0;
}
0
votes
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! :)
;
aftermain()
. Put,
afterplural
– vik_78