#include #include #include #define NUM_BITS_IN_BYTE 8 /* *Created by Drake Vidkjer *Created on 10/7/15 *Modified on 10/7/15 *Description: lab 2 file */ using namespace std; int main() { //define variables string input; //Print out the size in bytes of different primitive data types // cout << "An int takes up " << sizeof(int)/NUM_BITS_IN_BYTE << " bits of memory" << endl; // cout << "A double takes up " << sizeof(double)NUM_BITS_IN_BYTE << " bits of memory" << endl; // cout << "A char takes up " << sizeof(char) << " bits of memory" << endl; while(input != "e") { cout << "Find the size of a char (c), int (i), long (l), short (s), bool (b), float(f), double (d) or (e) to escape: "; cin >> input; //determine what user wants if( input == "e") { break; } else if(input == "c") { cout << "A char takes up " << sizeof(char)*NUM_BITS_IN_BYTE << " bits of memory" << endl; } else if(input == "i") { cout << "A int takes up " << sizeof(int)*NUM_BITS_IN_BYTE << " bits of memory" << endl; } else if(input == "l") { cout << "A long takes up " << sizeof(long)*NUM_BITS_IN_BYTE << " bits of memory" << endl; } else if(input == "s") { cout << "A short takes up " << sizeof(short)*NUM_BITS_IN_BYTE << " bits of memory" << endl; } else if(input == "b") { cout << "A boolean takes up " << sizeof(bool)*NUM_BITS_IN_BYTE << " bits of memory" << endl; } else if(input == "f") { cout << "A float takes up " << sizeof(float)*NUM_BITS_IN_BYTE << " bits of memory" << endl; } else if(input == "d") { cout << "A double takes up " << sizeof(double)*NUM_BITS_IN_BYTE << " bits of memory" << endl; } else { cout << "Invalid input" << endl; } } cout << endl; return 0; }