Login


Lost your password?

Don't have an account ? Register ×
  
CPP All : Data Types, Variables and Constants
Concept Notes and Resources
Concept Learning Code Sheets

Finding Size of CPP Data Types #1426

program shows use of sizeof operator to display the storage size of different data types

#include <iostream>
using namespace std;
int main(){
cout << "Size of boolean is " << sizeof(bool) << endl;
cout << "Size of char is " << sizeof(char) << endl;
cout << "Size of wchar_t is "<< sizeof(wchar_t) << endl;
cout << "Size of char16_t is "<< sizeof(char16_t) << endl;
cout << "Size of char32_t is "<< sizeof(char32_t) << endl;
cout << "Size of int is " << sizeof(int) << endl;
cout << "Size of short int is " << sizeof(short int) << endl;
cout << "Size of long int is " << sizeof(long ) << endl;
cout << "Size of long long int is " << sizeof(long long) << endl;
cout << "Size of float is " << sizeof(float) << endl;
cout << "Size of double is " << sizeof(double) << endl;
cout << "Size of long double is " << sizeof(long double) << endl;
return 0;
}

Integer data limits checking #2122

A program to check and understand integer data type data limits

#include <iostream>
using namespace std;
int main( )
{
int imax=2147483647;
int imin=-2147483648;
int imaxe=2147483648;
int imine=-2147483649;
cout<<"Integer max should be 2147483647"<<endl;
cout<<"Integer min should be -2147483648"<<endl<<endl;
cout<<"Attempted to print 2147483647"<<endl;
cout<<"Actually printed :"<<imax<<endl;
cout<<"Attempted to print -2147483648"<<endl;
cout<<"Actually printed :"<<imin<<endl;
cout<<"Attempted to print 2147483648"<<endl;
cout<<"Actually printed :"<<imaxe<<endl;
cout<<"Attempted to print -2147483649"<<endl;
cout<<"Actually printed :"<<imine<<endl;
return 0;
}
Solved Problems

Identify errors in fractional constants #2336

In the following representation of fractional constants, some of them may con

Identify errors in the variable names #2342

Identify errors in the following variable names and suggest the best alternat

Quizzes

Concept Notes:4  Code Sheets:2  Solved Problems:2  Quizzes:1
Back