Facebook
From 613, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 196
  1. // DataTypes.cpp : The data types to declare each of the variables is missing.
  2. // Based on the value being stored in the variable and the comments beside it,
  3. // fill in the data type at the beginning of each line. Then compile and run
  4. // program to make sure you selected the correct types.
  5. //
  6. // After you submit your answers, try changing the values stored in the
  7. // variables. What can you learn about the different data types?
  8. //
  9. #include <cstdlib>
  10. #include <iostream>
  11. using namespace std;
  12.  
  13. enum colorCode {
  14.     Green = 1,
  15.     Yellow = 5,
  16.     Red = 10
  17. } gradebookColor;
  18.  
  19. int main(int atgc, const char* arg[])
  20. {
  21.     unsigned int gradebookColor = colorCode::Green;
  22.     float classAverage = 90.7f; //Decimal number
  23.     char letterScore = 'A'; //Single letter
  24.     int testScore = 95; //Whole number value
  25.     float classTestAverage = 88.4f; //Decimal number, notice the 'f' at the end
  26.     //Stores list of values
  27.     bool isStudentPassing = true; //Could be true or false
  28.     cout << "The class average is currently "
  29.          << classAverage
  30.          << endl;
  31.     cout << "The class test average was "
  32.          << classTestAverage
  33.          << endl;
  34.     cout << "Your test score was "
  35.          << testScore
  36.          << endl;
  37.     cout << "Your current letter score is "
  38.          << letterScore
  39.          << endl;
  40.     cout << "The color of your gradebook entry is "
  41.          << gradebookColor
  42.          << endl;
  43.     cout << "Are you passing? "
  44.          << boolalpha //This line allows the word 'true' or 'false' to be printed instead of '0' or '1'
  45.          << isStudentPassing
  46.          << endl;
  47.     return 0;
  48. }

Replies to Untitled rss

Title Name Language When
Re: Untitled Gruff Terrapin text 3 Years ago.