Cyborg data type sizes. You have been given a job as a programmer on a Cyborg supercomputer. In order to accomplish some calculations, you need to know how many bytes the following data types use: char, int, float, and double. You do not have any manuals, so you can’t look this information up. Write a C++ program that will determine the amount of memory used by these types and display the information on the screen.

1 answer

// Programming Challenges of Chapter 2 on P77
// Written by Lanchuan Chang

#include <iostream>
using namespace std;

int main()
{
// 9. Cyborg Data Type Sizes
cout << " the size of a char is " << sizeof(char) << " bytes.\n";
cout << " the size of an int is " << sizeof(int) << " bytes.\n";
cout << " the size of a float is " << sizeof(float) << " bytes.\n";
cout << " the size of a double is " << sizeof(double) << " bytes.\n";

return 0;

}