This C++ Program which reads in the values of different primitive datatypes. The program uses input streams to take in the values of the primitive datatypes.
Here is source code of the C++ program which reads in the values of different primitive datatypes. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C++ Program to Read Primitive Datatypes
*/
#include <iostream>
using namespace std;
int main()
{
int integer;
char character;
float float_value;
double double_value;
bool boolean;
cout << "Non-zero value stands for true and "
<< "anything else for false " << endl;
cout << "Enter the boolean value : ";
cin >> boolean;
cout << "Enter an integer value : ";
cin >> integer;
cout << "Enter the character : ";
cin >> character;
cout << "Enter the float value : ";
cin >> float_value;
cout << "Enter the double value : ";
cin >> double_value;
cout << endl;
cout << "Integer : " << integer << endl
<< "Character : " << character << endl
<< "Float : " << float_value << endl
<< "Double : " << double_value << endl
<< "Boolean : " << boolean;
}
$ g++ main.cpp $ ./a.out Non-zero value stands for true and anything else for false Enter the boolean value : 1 Enter an integer value : 123 Enter the character : a Enter the float value : 12.3 Enter the double value : 12.333333 Integer : 123 Character : a Float : 12.3 Double : 12.3333 Boolean : 1
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.
Related Posts:
- Apply for Computer Science Internship
- Check Computer Science Books
- Check Programming Books
- Apply for C++ Internship
- Check C++ Books