Unit1 2(Operator)
Unit1 2(Operator)
Kukutla Alekhya
Copyright 2023 ©, ISBAT University, All rights reserved.
Learning Objectives
• Introducing the syntax and structure of C++ programming language, including basic data types,
control structures, functions, classes, and objects.
• Helping learners to understand the differences between C++ and other programming languages
such as C and Java.
• Teaching learners how to write and execute basic C++ programs using an integrated development
environment (IDE) or a compiler.
• Providing an overview of the standard C++ library, including its built-in functions and data
structures.
• Giving learners hands-on practice with C++ programming by guiding them through several examples
and exercises.
2
<iostream>
datatype variable_list;
int x;
float y;
char z;
The single line comment starts with // (double slash). Let's see an
example of single line comment in C++.
#include <iostream>
using namespace std;
int main()
{
int x = 11; // x is a variable
cout<<x;
Return 0;
}
Multi Line Comment
The C++ multi line comment is used to comment multiple lines of code. It is
surrounded by slash and asterisk (/∗ ..... ∗/). Let's see an example of multi
line comment in C++.
#include <iostream>
using namespace std;
int main()
{
/* declare and
print variable in C++. */
int x = 35;
cout<<x;
return 0;
}
Operators
#include <iostream>
using namespace std;
int main()
{
int x; // variable declaration.
int y; // variable declaration
int z; // variable declaration
cout<<"Enter the values of x and y";
cin>>x>>y;
z=x+y;
cout<<"Value of z is :"<<z;
return 0;
}
Relational operator
For example:
x=3
x>>3 // This statement means that we are shifting the three-bit
position to the right.
In the above example, the value of 'x' is 3 and its binary value is
0011. We are shifting the value of 'x' by three-bit position to the
right.
Bitwise Operators
#include <iostream>
using namespace std;
int main()
{
int x=5; // variable declaration
cout << (x>>1) ;
return 0;
}
Output :
2
19
Thank you