VARIABLES IN C++

SAIROSHNI

Variables

There are different types of  variables available in c++ with different keywords :
  • int - It stores integers without the decimals .(EX): 635 or -635
  • double - It stores floating point numbers with decimals.(EX): 19.55 or -19.55
  • char - It stores single characters and they are surrounded by single quotes.(EX):'a' and 'b'
  • string - It stores texts and they are surrounded by double quotes.(EX):"Gocourse"
  • boolean - It stores values with two states.(EX):True or False

Declaration Of Variables:

  • To create a variable, specify the type and assign the value.
  • To combine both text and a variable, separate them with the (<< )operator.
  • A variable name must only contain alphabets,digits and underscore.
  • A variable name must start with an alphabet or an underscore only. It cannot start with a digit.
  • No whitespace is allowed within the variable name.
  • A variable name must not be any reserved word or keyword. 
  • To add a variable to another variable ,you can use the (+) operator.
  • To declare more than one variable of the same type,use comma(,).



Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send