Saturday, May 9, 2009

C++ questions for IDE Dev?

Im quite new to C++ and im using the Dev compiler (the free one) the latest version and every time im using end1; an error comes up and says end1 undelcared. I inputed int main and using namespace std.





// carrots.cpp--food processing program





#include %26lt;iostream%26gt;





int main()


{


using namespace std;





int carrots;





cout%26lt;%26lt; "How many carrots do I have?" %26lt;%26lt; end1;


cin%26gt;%26gt; carrots;


cout%26lt;%26lt; "Here are two more";


carrots=carrots = 2;


cout%26lt;%26lt; "Now you have "%26lt;%26lt; carrots %26lt;%26lt; " carrots."%26lt;%26lt; end1;


return 0;


}

C++ questions for IDE Dev?
The end1 should be endl (note: the letter el, not the digit one at the end!) in two places. The endl stands for end-line.





Also, it should be





carrots = carrots + 2;


No comments:

Post a Comment