Skip to content

Instantly share code, notes, and snippets.

@Adals20
Created February 17, 2017 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adals20/491f77eb40d7c71d42f7932701318fc8 to your computer and use it in GitHub Desktop.
Save Adals20/491f77eb40d7c71d42f7932701318fc8 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <stdio.h>
using namespace std;
main()
{ /* PROGRAM TO PRINT OUT SPACE RESERVED FOR VARIABLES */
char c;
short s;
int i;
unsigned int ui;
unsigned long int ul;
float f;
double d;
long double ld;
cout << endl
<< "The storage space for each variable type is:"
<< endl;
printf("char: \t\t\t%d bits\n",int(sizeof(c)*8)); // \t means tab
printf("short: \t\t\t%d bits",sizeof(s)*8); cout << endl;
printf("int: \t\t\t%d bits",sizeof(i)*8); cout << endl;
printf("unsigned int: \t\t%d bits",sizeof(ui)*8); cout << endl;
printf("unsigned long int: \t%d bits",sizeof(ul)*8); cout << endl;
printf("float: \t\t\t%d bits",sizeof(f)*8); cout << endl;
printf("double: \t\t%d bits",sizeof(d)*8); cout << endl;
printf("long double: \t\t%d bits",sizeof(ld)*8); cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment