A very simple C++ operators and operands program example
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)
To do: Do some basic mathematics operations to demonstrate the C++ operators and operands
To show: How to use the C++ operators and operands demonstrated using mathematics operations example
// a simple mathematics operations
#include <iostream>
using namespace std;
int main(void)
{
// variables declaration assign names and types
float a, b, c;
// variables initialization, assign values
a = 2.0;
b = 5.0;
c = b / a;
cout<<"\nGiven a = 2.0, b = 5.0, c = b/a";
cout<<"\nc = "<<c;
c = c + (a/b);
cout<<"\nc = c + (a/b) = "<<c<<endl;
return 0;
}
Output example:
Given a = 2.0, b = 5.0, c = b/a
c = 2.5
c = c + (a/b) = 2.9
Press any key to continue . . .