GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — CPP-Tutorial/02_DataTypes_Variables.cpp at main · i2a-k/CPP-Tutorial Expand file tree/ Copy path02_DataTypes_Variables.cppMore file actions 53 lines (40 loc) · 1.64 KB / Copy path02_DataTypes_Variables.cppFile metadata and controls53 lines (40 loc) · 1.64 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 /* Variables: <type> <identifier>; (initialization) Types: int, float, char, double, bool int => integer => 2 Bytes, Example: (-inf,inf), Example: int number = 5; float => 4Bytes => Example: float pi = 3.14; double => 8Bytes => Example: double number = 2.558484543534313215; char => character => 1Byte => (-127,127) => ASCI, Example: char ch = 'A'; bool => boolean => 1 bit => True (!=0), False (0), Example: bool st = true; Identifiers: (a-z, A-Z, Underscore, 0-9) Valid Examples: Number1, NumberOne, Number_One, _Number Invalid Examples: 1Number, Number One 32 keywords is reserved for c++, like: int, float, for, if, break, continue, ... => int for = 5; => invalid! */ #include <iostream> using namespace std; int main(){ int _num1; //2Bytes (-32768,32768) //int for = 1; //This causes an error _num1 = 15; cout << _num1 << endl; //endl places a return in output (next output is shown in new line). int num2 = 5.25; float num3 = 5.25; //4Bytes float num4 = 7; cout << num2 << ", " << num3 << ", " << num4 << endl; char ch1 = 'A'; //1Byte (ASCI) , (-127,127) char ch2 = 'AmirAli'; //Last character stores in ch2 cout << ch1 << ", " << ch2 << endl; bool st1 = true; //1bit, True = 1, False = 0 bool st2 = false; cout << st1 << ", " << endl; float num5 = 10.789465; double num6 = 10.789465; //8Bytes cout << num5 << ", " << num6 << endl; int num7 = 0b01011101; //Binary int num8 = 0342; //Octal int num9 = 0x2AB3; //Hexadecimal float num10 = -23.47e5; cout<< num7 << ", " << num8 << ", " << num9 << ", " << num10 << endl; } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |