Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a procedural C++ program called datatype_sizes.cc that will output the si

ID: 3925217 • Letter: C

Question

Create a procedural C++ program called datatype_sizes.cc that will output the sizes in bytes of the datatypes long int, float, double and float *. Make your program simple and and its logic straightforward. For example, the program logic can consist solely of four printf() statements. . With the exception of warnings about parameters argc and argv of function main() not being used, your program must compile without errors or warnings when the -Wall and -Wextra options are given to the C++ compiler. Hint: use the C/C++ function sizeof(). The return type of sizeof() is size_t. To have printf(3) output a value of type size_t, use the “%zu” or “%zd” format specification.

Note: overly and unnecessarily complex programs may be docked marks.

Explanation / Answer

#include <stdio.h>
int main() {
   printf("Size of long int = %zu ",sizeof(long int));
   printf("Size of float = %zu ",sizeof(float));
   printf("Size of double = %zu ",sizeof(double));
   printf("Size of float* = %zu ",sizeof(float *));
}

/* sample output

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote