Modify the program below using the sizeof() operator to display the amount of st
ID: 3620305 • Letter: M
Question
Modify the program below using the sizeof() operator to display the amount of storage your computer reserves for each data type. With this information determine whether your computer set aside storage for the variables in the order in which they were declared.Code:
#include <iostream>
using namespace std;
int main(void){
int num , Cout; // you cant use small c, as cout is a keyword in c++.
long date;
float slope;
double power;
cout <<"address for Num: " << &num << endl;
cout <<"address for cout: " << &Cout << endl;
cout <<"address for date: " << &date << endl;
cout <<"address for slope: " << &slope << endl;
cout <<"address for power: " << &power << endl;
return 0;
}
Explanation / Answer
OutPut:: Size for Num: 4 Size for Cout:4 Size for date: 4 Size for slope: 4 Size for power: 8 now, i know that compilers go in order from top to bottom in the main. So, It has to set aside storage for variables in the order which they were declared. #include using namespace std; int main(void){ int num , Cout; // you cant use small c, as cout is a keyword in c++. long date; float slope; double power; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.