Simple C++ variable program

C++ variable to store the data in memory variable are the register to hold the data at certain memory loaction . 
#Beginner

In gcc C++ compiler using namespace std



#include <iostream>
using namespace std;

int main()
{
bool value = 0;
/* boolean datatype 0 or 1 and true or false */
cout << "boolean number is :" << value << endl;

short int short_int = 32767;
/* short int is -32,768 to +32,767 */
cout << "short int number is :" << short_int << endl;

unsigned short int un_short_int = 65535;
/*only postive short int is 0 to 65535 */
cout << "postive short number is :" << un_short_int << endl;

int int_number = 2147483647;
/* normal int is -2147483648 to +2147483647 */
cout << "integer number is :" << int_number << endl;

unsigned int un_int_number = 4294967295;
/* postive normal int is 0 to  4294967295 */
cout << "postive integer number is :" << un_int_number << endl;

long int long_int = 2147483647;
/* long int is -2147483648 to +2147483647 */
cout << "long integer number is :" << long_int << endl;

unsigned long int un_long_int = 4294967295;
/* postive long int is 0 to 4294967295 */
cout << "postive long integer number is :" << un_long_int << endl;

float float_number = 3.4028235E+38;
/* floating point number Negative range:

-3.4028235E+38 to -1.4E-45  Positive range:

1.4E-45 to 3.4028235E+38 */
cout << "floating point number is :" << float_number << endl;

double double_number = 1.7976931348623157E+308;
/* double number Negative range:

-1.7976931348623157E+308 to -4.9E-324

Positive range:

4.9E-324 to 1.7976931348623157E+308 */
cout << "double number is :" << double_number << endl;

long double long_double = 1.18E+4932;
/* long double number Negative range:

-1.18E+4932 to -3.37E-4932

Positive range:

3.37E-4932 to 1.18E+4932 */
cout << "long double number is :" << long_double << endl;

char character = 'A';
/* single alphabet */
cout << "single letter is :" << character << endl;

string name = "sarveshcreater";
/* more than one alphabets */
cout << "my name is :" << name << endl;

return 0;
}
copy


Output



boolean number is :0
short int number is :32767
postive short number is :65535
integer number is :2147483647
postive integer number is :4294967295
long integer number is :2147483647
postive long integer number is :4294967295
floating point number is :3.40282e+38
double number is :1.79769e+308
long double number is :inf
single letter is :A
my name is :sarveshcreater

[Program finished]


Need of Programmer

Need of Programmer

Comments

Popular posts from this blog

Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas: area = radius * radius * π volume = area * length

Write a program that reads the subtotal and the gratuity rate, then computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity rate, the program displays $1.5 as gratuity and $11.5 as total.

Write a program that prompts the user to enter the min- utes (e.g., 1 billion), and displays the number of years and days for the minutes. For simplicity, assume a year has 365 days