Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.37 KB

Variables&DataTypes-C++.md

File metadata and controls

30 lines (19 loc) · 1.37 KB

C Programming Language

Variables in C

Variables are references used to store information for a future use

  • main data types:

    1. Int
    2. Float
    3. Double
    4. Char

Rules for Variables

  • As a bonus tip right from the start, you can create more than one variable of the same type at a time by listing them with commas between their names, like type variable1, variable_2, variable_3, variable4.
  • Names can be composed of upper and lower case letters, numbers, and underscores.
  • The first character must be a letter (upper or lower case).
  • No keywords are allowed as the full name (int is not allowed but int_count would work).

Data Types

  • In C, you must specify the type of the variable when you declare it. Once it is set, that type of information is the only type that can go into that variable. So if you create a variable of type int, which can only store whole numbers, you will not be able to store "a" nor 1.2 in it. The table below details these types we are going over and what information can go into each.

printf()

  • printf works like the print function in Python or the console.log() in Javascript
  • The basic format is printf("string to display", [list of optional parameters])