C++ lecture 4 in Urdu
Operators
Arithmetic operator..
|
+
|
Adds
two operands
|
A + B
will give 30
|
|
-
|
Subtracts
second operand from the first
|
A - B
will give -10
|
|
*
|
Multiplies
both operands
|
A * B
will give 200
|
|
/
|
Divides
numerator by de-numerator
|
B / A
will give 2
|
|
%
|
Modulus
Operator and remainder of after an integer division
|
B % A
will give 0
|
|
++
|
Increment operator, increases integer
value by one
|
A++
will give 11
|
|
--
|
Decrement operator, decreases integer
value by one
|
A--
will give 9
|
Realtional operator…
|
Operator
|
Description
|
Example
|
|
==
|
Checks if the values of two operands are equal or not, if yes
then condition becomes true.
|
(A == B) is not true.
|
|
!=
|
Checks if the values of two operands are equal or not, if
values are not equal then condition becomes true.
|
(A != B) is true.
|
|
>
|
Checks if the value of left operand is greater than the value
of right operand, if yes then condition becomes true.
|
(A > B) is not true.
|
|
<
|
Checks if the value of left operand is less than the value of
right operand, if yes then condition becomes true.
|
(A < B) is true.
|
|
>=
|
Checks if the value of left operand is greater than or equal
to the value of right operand, if yes then condition becomes true.
|
(A >= B) is not true.
|
|
<=
|
Checks if the value of left operand is less than or equal to
the value of right operand, if yes then condition becomes true.
|
(A <= B) is true.
|
Logical Operator….
|
Operator
|
Description
|
Example
|
|
&&
|
Called
Logical AND operator. If both the operands are non-zero, then condition
becomes true.
|
(A
&& B) is false.
|
|
||
|
Called
Logical OR Operator. If any of the two operands is non-zero, then condition
becomes true.
|
(A ||
B) is true.
|
|
!
|
Called
Logical NOT Operator. Use to reverses the logical state of its operand. If a
condition is true, then Logical NOT operator will make false.
|
!(A
&& B) is true.
|
Bitwise operator..
|
q |
p
& q
|
p | q
|
p ^ q
|
|
|
0
|
0
|
0
|
0
|
0
|
|
0
|
1
|
0
|
1
|
1
|
|
1
|
1
|
1
|
1
|
0
|
|
1
|
0
|
0
|
1
|
1
|
Jo right side py value hai wo p k
lay hai (0 1 0 1)
Abe k program banty hai jes me arithmetic operator use hung
y
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr() ; // use for clear output screen
int a,b,c ,d,e;
a=5+2;
b=5-1;
c=3*4;
d=5/2;
e=5%2;
cout<<” Addition of 5+2 is equal to =”<< a<<endl;
cout<<”subtraction of 5-1 is equal to =”<<b<<endl;
cout<<”Multiplaction of 3*4 is equal to =”<<c<<endl;
cout<<”division of 5/2 is equal to =”<<d<<endl;
cout<<”remendir of 5%2 is equal to =”<<e<<endl;
cout<<” Hacking And every Programming Logic”<<endl;
getch();
}
#include<conio.h>
void main()
{
clrscr() ; // use for clear output screen
int a,b,c ,d,e;
a=5+2;
b=5-1;
c=3*4;
d=5/2;
e=5%2;
cout<<” Addition of 5+2 is equal to =”<< a<<endl;
cout<<”subtraction of 5-1 is equal to =”<<b<<endl;
cout<<”Multiplaction of 3*4 is equal to =”<<c<<endl;
cout<<”division of 5/2 is equal to =”<<d<<endl;
cout<<”remendir of 5%2 is equal to =”<<e<<endl;
cout<<” Hacking And every Programming Logic”<<endl;
getch();
}
Ham ne int type k 5 variable liy ur us ko value de ab ham es
ke value change nahe kar sakty es ka output kuch u ho ga ha ye endl newline par
lany k lay use karty hai
Addition of 5+2 is equal to = 7
subtraction of 5-1 is equal to=4
Multiplaction of 3*4 is equal to =12
division of 5/2 is equal to =2
remendir of 5%2 is equal to= 1
Hacking And every Programming Logic
ye 5/2 wesy 2.5 ata hai par ham ne data type int use kia hoa float nahe es lay point wali value show nahe ho ge agr int k bajy float use karty to per ans.. 2.5 ata
Ap log khud se b koi program bana looo Addition of 5+2 is equal to = 7
subtraction of 5-1 is equal to=4
Multiplaction of 3*4 is equal to =12
division of 5/2 is equal to =2
remendir of 5%2 is equal to= 1
Hacking And every Programming Logic
ye 5/2 wesy 2.5 ata hai par ham ne data type int use kia hoa float nahe es lay point wali value show nahe ho ge agr int k bajy float use karty to per ans.. 2.5 ata
Good luck
No comments:
Post a Comment