Facebook
From Gruff Terrapin, 3 Years ago, written in Plain Text.
This paste is a reply to Untitled from 613 - go back
Embed
Viewing differences between Untitled and Re: Untitled
// DataTypes.cpp : This compiled fine for me with g++. The data types to declare each of the variables is missing.
// Based on the value being stored in the variable and the comments beside it,
// fill in the data type at the beginning of each line. Then compile and run
// program to make sure you selected the correct types.
//
// After you submit your answers, try changing the values stored in the
// variables. What can you learn about the different data types?
//
#include 
#include 
using namespace std;
 
enum colorCode {
    Green = 1,
    Yellow = 5,
    Red = 10
} gradebookColor;
 
int main(int atgc, const char* arg[])
{
    unsigned int gradebookColor = colorCode::Green;
    float classAverage = 90.7f; //Decimal number
    char letterScore = 'A'; //Single letter
    int testScore = 95; //Whole number value
    float classTestAverage = 88.4f; //Decimal number, notice the 'f' at the end
    //Stores list of values
    bool isStudentPassing = true; //Could be true or false
    cout << "The 
output is:
The 
class average is currently "
         << classAverage
         << endl;
    cout << "The 
90.7
The 
class test average was "
         << classTestAverage
         << endl;
    cout << "Your 
88.4
Your 
test score was "
         << testScore
         << endl;
    cout << "Your 
95
Your 
current letter score is "
         << letterScore
         << endl;
    cout << "The 
A
The 
color of your gradebook entry is "
         << gradebookColor
         << endl;
    cout << "Are 
1
Are 
you passing? "
         << boolalpha //This line allows the word 'true' or 'false' to be printed instead of '0' or '1'
         << isStudentPassing
         << endl;
    return 0;
}
true