New to C++ Programming

This is a discussion on New to C++ Programming within the C++ Programming forums, part of the General Programming Boards category; I am taking a C++ programming class and I'm new to this and I just don't get sum of the ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    5

    New to C++ Programming

    I am taking a C++ programming class and I'm new to this and I just don't get sum of the assignments.. I am suppose to write a program that will display the square root of the sum of num1 and num2. And I can't figure it how.. Can anyone help me out..

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Add the two numbers together, then send that value to the sqrt() function in math.h.

    Please don't expect someone on these boards to do your assignment for you. If you haven't been following what's going on in class, you can read some of the tutorials on this web site.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    5
    I don't expect someone on this site to do my assignment for me I just don't understand it and I keep getting errors when I do exactly what you said.

  4. #4
    Registered User Scribbler's Avatar
    Join Date
    Sep 2004
    Location
    Aurora CO
    Posts
    266
    Post your code (don't forget to use the [code] tags), and the errors, then perhaps we can help

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    5
    [QUOTE]

    Here is the error
    -------------------Configuration: T5ConE03 - Win32 Debug--------------------
    Compiling...
    T5ConE03.cpp
    T5ConE03.cpp(22) : error C2065: 'sqRoot' : undeclared identifier
    T5ConE03.cpp(26) : error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acc
    eptable to the predefined operator
    Error executing cl.exe.

    T5ConE03.exe - 2 error(s), 0 warning(s)

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    5
    [QUOTE]

    The books sucks to be a Intro to Programming book especially if you have never done programming before like me..

    I don't understand how to post the program on the site but I think I am just frustrated with this stupid assignment right now.

  7. #7
    Registered User Scribbler's Avatar
    Join Date
    Sep 2004
    Location
    Aurora CO
    Posts
    266
    Here is an example of how sqrt is used...

    Code:
    #include <iostream>
    #include <cmath>
    
    using std::cout;
    using std::endl;
    using std::cin;
    using std::sqrt;
    
    int main()
    {
    	cout << sqrt(144) << endl; /* Will print 12 to stdout */
    	
    	cin.get(); /* Holds the console window open depending on the compiler you are using */
    	
    	return 0;
    }
    Last edited by Scribbler; 03-27-2005 at 10:10 PM.

  8. #8
    Registered User vermilion's Avatar
    Join Date
    Mar 2005
    Location
    マザーボード
    Posts
    2

    At shawnaj7825 ok use code tags , is really easy to use, is like using html beguin with [code] and finish with [ / code ] but with out space, and It's a relief for the eyes.
    well just relax and all the code will appear. Take your time, don't rush yourself. And read the tutorials http://www.cprogramming.com/begin.html
    幸運

  9. #9
    Registered User
    Join Date
    Mar 2005
    Posts
    5
    Thank you scribbler and vermilion... That was all I needed.. I didn't need someone to think I was trying to get them to my work I just need a example or some form of help because the book I am using sucks and my instructor doesn't even provide examples to help us out. I really appreciate ya'll taking time out to reply... Again thank you..

  10. #10
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Quote Originally Posted by shawnaj7825
    ...I just need a example or some form of help because the book I am using sucks and my instructor doesn't even provide examples to help us out.
    There are plenty of C++ books, so I suggest you get a jump on the rest of your class, and buy a better one:

    1) Ivor Horton's Beginning C++
    A fairly rigorous book, with detailed explanations, which you could use as a reference for things you don't understand.

    2) Sam's Teach Yourself C++ in 21 Days
    A book that is a bit easier, and it's recommended by lots of beginners.

    3) C++: A Beginner's Guide
    A really basic book, which is the shortest book of the three.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21