Errors in code

Posted on 2004-10-21
Last Modified: 2012-06-21
Hi everyone,

I am a beginning programmer in C++ learning this on my own with the help from fellow experts-exchange comrades, with two question hoping someone can help.  The first, I would like two get everyone's input on which is the best way to learn the C++ programming language? On your own or in an acedemic environment ?

The second, I am trying to compile this source file taken from Sams teach yourself C++ in 21days Ex.1. p.21 using Borland's C++ Comiler 5.5.1, but i am getting these error messages:

//Exercise 1 ch.1

#include <iostream>

int main()
  int x = 5;
  int y = 7;
  std::cout << "\n";
  std::cout << x + y << " " << x * Y;
  std::cout << "\n";
  return 0;

Warning W8084 Ex1.cpp 10: Suggest parenthesis to clarify precedence in function main()
Error E2451 Ex1.cpp 10: Undefined symbol in function main()
Warning W8004 Ex1.cpp 13: 'x' is assigned a value that is never used in the function main()
Warning W8004 Ex1.cpp 13: 'y' is assigned a value that is never used in the function main()
****1 errors in compile****

Thanks, it's great to have joined a site with so much IT related assistance and information!!!!

Question by:studious01
    LVL 4

    Expert Comment

    Either way is acceptable. I learned C in an academic environment, taught myself c++/java/python....
    To me, it just helps to have someone around that knows what they're doing to explain things.

    Try using parens around the x + y  and x * y  and it will work.  also on that same line, change it from a Y to a y.
    LVL 4

    Accepted Solution

    The parens should look like:

    std::cout << (x+y) << " " << (x*y);

    Author Comment

    Thanks, nagraves that did!
    Just required a little more effort.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Anonabox PRO Tor & VPN Router

    PRO is the most advanced way to fortify your privacy and online anonymity by layering the Tor network with VPN services. Use both together or separately, and without needing to download software onto your devices.

    When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
    IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now