C++ examples for Language Basics:Variable
C++ program that demonstrates the C++ comments and shows a few variables and their declarations.
#include <iostream> using namespace std; int main()/*w w w . j a va2 s.com*/ { int i, j; // These three lines declare four variables. char c; float x; i = 4; // i and j are both assigned integer literals. j = i + 7; c = 'A'; // All character literals are enclosed in single quotations. x = 9.087; x = x * 4.5; cout << i << ", " << j << ", " << c << ", " << x << "\n"; return 0; }