Asked by Anonymous
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.
Answers
Answered by
Anonymous
// 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;
}
// 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;
}
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.