Fundamentals and Operators
Fundamentals and Operators
Fundamentals
and
Operators
C A M A R I N E S S U R P O LY T E C H N I C C O L L E G E S | C O L L E G E O F C O M P U T E R S T U D I E S
Learning Objectives
• Outline the program structure of C++ programming language.
• Create a blank text file using the Dev C++ editor and
name it as source.cpp
First, let us create an empty C++ program that does nothing.
The content of the source.cpp file is:
#include <iostream>
int main()
{
std::cout << "Hello World!";
}
#include <iostream>
-The statement includes the iostream header into our source file via
the #include directive.
std::cout << "Hello World!";
- std::cout allows us to send text to the console, so when we run our
application we see that the text “Hello World!” is printed.
CCIT 102 – CP 1 CAMARINES SUR POLYTECHNIC COLLEGES | COLLEGE OF COMPUTER
Other Program Examples
C++ Variables
• In programming, a variable is a container (storage
area) to hold data.
C++ Literals
• Literals are data used for representing fixed values.
They can be used directly in the code. For example 1,
2.5, 'c' etc.
C++ Constants
• In C++, we can create variables whose value cannot
be changed. For that, we use the const keyword.
Here's an example:
Types
• Every entity has a type. What is a type? A type is a
set of possible values and operations.
Data Type Meaning
int Integer
float Floating-point
double Double Floating-point
char Character
wchar_t Wide Character
bool Boolean
void Empty
1. int
• C++ int
• For example,
int salary = 85000;
• For example,
float area = 64.74;
double volume = 134.64534;
3. C++ char
• C++ char
• For example,
char test = 'h';
4. C++ wchar_t
• Wide character wchar_t is similar to the char data
type, except its size is 2 bytes instead of 1.
• For example,
wchar_t test = L' 'ם// storing Hebrew character;
5. C++ bool
• The bool data type has one of two possible values:
true or false.
• For example,
bool cond = false;
5. C++ void
• The void keyword indicates an absence of data. It
means "nothing" or "no value".
•Arithmetic Operators
•Relational Operators
•Logical Operators
•Bitwise Operators
•Assignment Operators
•Misc Operators
< Checks if the value of left operand is less than the value of (A < B) is true.
right operand, if yes then condition becomes true.
>= Checks if the value of left operand is greater than or equal (A >= B) is not
to the value of right operand, if yes then condition becomes true.
true.
<= Checks if the value of left operand is less than or equal to (A <= B) is true.
the value of right operand, if yes then condition becomes
true.
CCIT 102 – CP 1 CAMARINES SUR POLYTECHNIC COLLEGES | COLLEGE OF COMPUTER
Operators in C++
Logical Operators
There are following relational operators supported by C++ language
Assume variable A holds 10 and variable B holds 20, then −