home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / PROGRAM / CPTUTS22.ZIP / MESSAGE.CPP < prev    next >
C/C++ Source or Header  |  1992-01-20  |  1KB  |  48 lines

  1.                                    // Chapter 1 - Program 3
  2. #include <iostream.h>
  3. #include <string.h>
  4.  
  5. main()
  6. {
  7. int index;
  8. float distance;
  9. char letter;
  10. char name[25];
  11.  
  12.    index = -23;
  13.    distance = 12.345;
  14.    letter = 'X';
  15.    strcpy(name,"John Doe");
  16.  
  17.    cout << "The value of index is "    << index    << "\n";
  18.    cout << "The value of distance is " << distance << "\n";
  19.    cout << "The value of letter is "   << letter   << "\n";
  20.    cout << "The value of name is "     << name     << "\n";
  21.  
  22.    index = 31;
  23.    cout << "The decimal value of index is " << dec << index << "\n";
  24.    cout << "The octal value of index is " << oct << index << "\n";
  25.    cout << "The hex value of index is " << hex << index << "\n";
  26.    cout << "The character letter is " << (char)letter << "\n";
  27.  
  28.    cout << "Input a decimal value --> ";
  29.    cin  >> index;
  30.    cout << "The hex value of the input is " << index << "\n";
  31. }
  32.  
  33.  
  34.  
  35.  
  36. // Result of execution
  37. //
  38. // The value of index is -23
  39. // The value of distance is 12.345
  40. // The value of letter is X
  41. // The value of name is John Doe
  42. // The decimal value of index is   31
  43. // The octal value of index is   37
  44. // The hex value of index is   1f
  45. // The character letter is X
  46. // Input a decimal value --> 999
  47. // The hex value of the input is 3e7
  48.