first hint of object oriented programming
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 54 55 56 57 58 | /******************************************************* * MYCPLUS Sample Code - https://www.mycplus.com * * * * This code is made available as a service to our * * visitors and is provided strictly for the * * purpose of illustration. * * * * Please direct all inquiries to saqib at mycplus.com * *******************************************************/ #include <iostream.h> #include <string.h> main() { int index; float distance; char letter; char name[25]; index = -23; distance = 12.345; letter = 'X'; strcpy(name,"John Doe"); cout << "The value of index is " << index << "\n"; cout << "The value of distance is " << distance << "\n"; cout << "The value of letter is " << letter << "\n"; cout << "The value of name is " << name << "\n"; index = 31; cout << "The decimal value of index is " << dec << index << "\n"; cout << "The octal value of index is " << oct << index << "\n"; cout << "The hex value of index is " << hex << index << "\n"; cout << "The character letter is " << (char)letter << "\n"; cout << "Input a decimal value --> "; cin >> index; cout << "The hex value of the input is " << index << "\n"; } // Result of execution // // The value of index is -23 // The value of distance is 12.345 // The value of letter is X // The value of name is John Doe // The decimal value of index is 31 // The octal value of index is 37 // The hex value of index is 1f // The character letter is X // Input a decimal value --> 999 // The hex value of the input is 3e7 |