Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 6 months ago

Identify & edit the following code. There are 10 errors.?

#include <iostream>

using namespace std;

int main ( )

int numberOfYears;

cout << "Welcome to ECGR 2103" endl;

cout << This will be an amazing class! ;

cout << How many years of programming experience do you have?"<< endl

cin<< numberOfYears;

cout<< “numOfYears”<< " years is more than enough experience !";

return;

}

3 Answers

Relevance
  • 6 months ago

    #include <iostream>

    using namespace std;

    int main ( ) {

    int numberOfYears;

    cout << "Welcome to ECGR 2103" << endl;

    cout << "This will be an amazing class!" << endl;

    cout << "How many years of programming experience do you have?"<< endl;

    cin >> numberOfYears;

    cout<< numberOfYears << " years is more than enough experience !" << endl;

    return 0;

    }

    • Login to reply the answers
  • 6 months ago

    If you haven't set up a C++ compiler on your home computer, some simple things like this can be done at IdeOne.com, where you can edit, compile and run single-source file programs that don't need file I/O and can run with a small, pre-coded standard input stream (std::cin in C++).

    If you have a Windows system, Code::Blocks is probably the easiest IDE to install to get an editor, compiler and debugger for modern C++. On a Mac, get a free Apple ID and download a free, older copy of Xcode to get a recent C++ compiler. On Linux, you're already supposed to know how to use the package manager to get the GNU g++ compiler or the LLVM clang compiler.

    I mention all this because the only reason to take a C++ programming class is to learn how to program in C++, and you're not going to learn that without spending time coding, making errors while you're at it, interpreting compiler error messages. You're certainly not going to get there by asking someone else to do that for you.

    I suggest you find and fix errors one at a time. This is a good idea in most languages, but it's *extremely* valuable in C or C++ where the compilers can often generate dozens of messages from a single error. Start with the first error or warning message; fix that an recompile. You can save a little time by looking for the same error on subsequent lines.

    Have a working sample program open in another window (or a textbook open to the page) just so you have something good to compare the broken program to. It helps.

    • Login to reply the answers
  • Fred
    Lv 7
    6 months ago

    What makes you think this is a place where others will do your homework?

    • Login to reply the answers
Still have questions? Get your answers by asking now.