Printing various C++ data types on the standard output

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info:

To do: Printing various C++ data types on the standard output using console output, cout method

To show: How to print various C++ data types on the standard output using console output, cout

 

#include <iostream>

using namespace std;

 

// main(void) function

int main(void)

{

int a = 3000; // positive integer data type

float b = 4.5345; // float data type

char c = 'Z'; // char data type

long d = 31456; // long positive integer data type

long e = -31456; // long -ve integer data type

int f = -145; // -ve integer data type

short g = 120; // short +ve integer data type

short h = -120; // short -ve integer data type

double i = 5.1234567890; // double float data type

float j = -3.24; // float data type

 

// printing the data types

cout<<"Welcome Ladies and Gentlemen!!\n";

cout<<"Here are the list of the C/C++ data type\n";

cout<<"\n1. This is positive integer number (int):\t\t"<<a;

cout<<"\n2. This is positive float number (float):\t\t"<<b;

cout<<"\n3. This is negative float number (float):\t\t"<<j;

cout<<"\n4. This is character data (char):\t\t\t"<<c;

cout<<"\n5. This is long positive integer number (long):\t"<<d;

cout<<"\n6. This is long negative integer number (long):\t"<<e;

cout<<"\n7. This is negative integer number (int):\t\t"<<f;

cout<<"\n8. This is short positive integer number (short):\t"<<g;

cout<<"\n9. This is short negative integer number (short):\t"<<h;

cout<<"\n10. This is double positive float number (double):\t"<<i;

cout<<"\n11. \'This is a lateral string\'\n";

 

return 0;

}

 

Output example:

 

Welcome Ladies and Gentlemen!!

Here are the list of the C/C++ data type

1. This is positive integer number (int): 3000

2. This is positive float number (float): 4.5345

3. This is negative float number (float): -3.24

4. This is character data (char): Z

5. This is long positive integer number (long): 31456

6. This is long negative integer number (long): -31456

7. This is negative integer number (int): -145

8. This is short positive integer number (short): 120

9. This is short negative integer number (short): -120

10. This is double positive float number (double): 5.12346

11. 'This is a lateral string'

Press any key to continue . . .

 

 

C and C++ Programming Resources | C & C++ Code Example Index