Beruflich Dokumente
Kultur Dokumente
Group :D
Members:
int main ()
return 0;
Other Way
int main ()
return 0;
#include <iostream>
int main ()
// line comment
#include <iostream>
int main ()
World!
C++ program
Variables Data Types:-
a = 5;
b = 2;
a = a + 1;
result = a - b;
Answer is 4
Identifiers
valid.
do, double, dynamic_cast, else, enum, explicit,
export, extern, false, float, for, friend, goto,
if, inline, int, long, mutable, namespace, new,
operator, private, protected, public, register,
Very important: The C++ language is a
"case sensitive" language. That means that
an identifier written in capital
identifiers.
Initialization of variables
For example, if we want to declare an int
variable called a initialized with a value of 0 at
the moment in which it is
int a = 0;
int main ()
b = 4; // a:10, b:4
a = b; // a:4, b:4
Arithmetic operators ( +, -, *, /, % )
a = 11 % 3;
int main ()
int a, b=3;
a = b;
cout << a;
Increase and decrease (++,
--)
c++;
c+=1;
c=c+1;
Relational and equality
operators ( ==, !=, >, <, >=, <= )
(7 == 5) // evaluates to false.
(3 != 2) // evaluates to true.
int main ()
int a,b,c;
a=2;
b=7;
c = (a>b) ? a : b;
Comma operator ( , )
a = (b=3, b+2);
Would first assign the value 3 to b, and then
assign b+2 to variable a. So, at the end,
variable a would contain the value 5 while b
contains 5