C++ program that demonstrates the C++ comments and shows a few variables and their declarations. - C++ Language Basics

C++ examples for Language Basics:Variable

Description

C++ program that demonstrates the C++ comments and shows a few variables and their declarations.

Demo Code

#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;
}

Result


Related Tutorials