What's the glitch?

Sep 19, 2014 at 8:18pm

#inlcude <iostream>
#include <cmath>
using namespace std;

int main()
{
for (int x(0); x<6; x++)
{
cout<< "\t" << x << "\t"<< sqrt(x)<< "\n";

}
return 0;
}
Sep 19, 2014 at 8:22pm
Many of the functions in <cmath> are not meant to be used with integral types.
Sep 19, 2014 at 8:23pm
Try spelling #include correctly on line 1.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Sep 19, 2014 at 8:28pm
Thanks man, AbstractionAnon..Even I was thinking about how to edit my posts! (:
Sep 19, 2014 at 8:30pm
EDIT: You deleted and reposted a different post while I was writing. It is not clear to me whether you solved your problem.

The code compiles fine for me after fixing the "inlcude" typo. It even generates the correct output. What compiler are you using? Some have issues with <c****> headers and overload resolution because they are non-conforming (e.g. old MSVC versions).
Last edited on Sep 19, 2014 at 8:31pm
Sep 19, 2014 at 8:39pm
Ya..It was just the typo!Problem solved.
I've got an other doubt..If you care to explain..
What are the functions of \v and \f..Any link related to this would be appreciated!
Sep 19, 2014 at 8:45pm
Those are escape sequences, most languages and tools support them. For C++:
http://en.cppreference.com/w/cpp/language/escape
Note that some are no longer relevant in this current day and age (e.g. bell and backspace)
Last edited on Sep 19, 2014 at 8:46pm
Sep 19, 2014 at 8:50pm
Thanks LB
Topic archived. No new replies allowed.