Declare a variable

hello, i am a beginner with c++

i am trying to solve this problem

Declare a variable x , suitable for storing values like 3.14159 and 6.02E23.

so i wrote

x=3.14159

but getting a compiler error saying i need to insert something before the x

any help

thank you
float x = 3.14159;
You should find yourself a tutorial..
Thank you

yeah i been doing the reading on this website and also from a book i bought.
Last edited on
I think he meant read a tutorial
for instance this page should do the trick

http://www.cplusplus.com/doc/tutorial/variables/

well i guess so but trying to learn this on my own


Don't do that. Work yourself through the tutorial on this site to get most of the basics down, and then grab a good C++ book (like Stroustrups "The C++ Programming Language") to learn more about the language. Trying to teach yourself without having at least the basics covered will only lead you to learn complete nonsense that you have assembled based on what you observe, which you have to unlearn later on.
Last edited on
Topic archived. No new replies allowed.