Create a procedural C program called datatypesizescc that wi

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.

Solution

#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

*/

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 pro

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site