Professional Documents
Culture Documents
};
i
accepte
019 the stuae
sll2n
display ofa
todW
endl:u2E 17112saiduob aulsy
iiieei marks iugiuo
end]:
end]: and liw to
program? ad sd the nott3nut
user o
<« << sequence.
i << displayingsr
ue2;esue
valuel
value2 follows: a uto
num pnibsosg
from Anoen
following <<
<< <«
as escape
number
" lo "\t" structure
= =
isprogram sris STgoig
is is \t <<
the a the number:";lot
value2
valuel num
of accept a
output preceding
16 12 implementing << create
= =
of entered:"
#include val 6; /6; of
<iostream.
h> is is to #include
<iostream.h>
the / value
value valuel
ue2 to #include
<iostream.h>
the program
valuel,
24 3 val a 8 8
program
be 24* "The
"The of "Enter
number:
will 12 outputof of number
by "You You
entered:
8 struct
marks
int
main) 0return
; Cin
>>
num;
What double
valuel=
value2=
<< c< value a
value
Write
int
main
0
int
num;<< << 0; aWrite int
main)
2
Chapter coutcout The return
cout Cout Output: a
Q12. The The Enter
} Q13. QL4.
Ans. Ans. Ans.
º
114
C++
Basics
117
operators.
<< <<
num t+num
increment
is<<
<<
is
operator. Postfix increment
increment
36.666667 endl:
endl; and
addition endl; <<
num
post pre
is << Prefix
value <<s << applying
applying is<<
num
ns the the num
tis Fahrenheit
implement " implement <<
Fahrenheita operator. is afterafter
4
+ is of
value
2 num num num
of to addition
#include
<iostream,
h> of 6
to #include
<iostream.h>
program
conversion "Addition is of of of
4
program
+ Value ValueValueFinal
in
the 2 endl;endl;
value of () -2;
int
main int
num
<<"<<"<<"<<"
a int
main() 4: return
0; a return
0;
Output: celsiusWrite Using + << Addition
Write Output:
Enter
s;
int
=2 cout Output: num++;
Cout Cout COut Cout
98 // s
O18. Q19.
Ans. Ans.
directive.
noinu result
enumeration
nicq preprocessor <<
n
Jul) "
ot is
of = sit endl;
<< value
concept summer
armsa
#define Fahrenheit
endl;
<<
||
the ems "
Jun the Fahrenheit
implement
=
<<It
is oiteso
summer
implement of
summer conversion
Jun; *5)/9
to <iostream.
h>
#include in
||
program = to ((y-32)
#include
<iostream
.h>
valuE
May
summer
{month
enum
program m celsius
result
cel(x);:
Feb,Mar,
Apr,May,Jun,Jul,Aug,Sep,Oct,Nov, = Enter
double
result;
a main()
int Dec Cout cel(y)
Write month
(summer end1;
return
0; It
is
Summer int
main(
)
Chapter
2116 " cin <<"return
Jan, a double
x >X; 0;
enum Output: Write #define c
Q16. { }: if Cout Cout
Q17.
Ans.
assignment
C++
Basics
119
<<""
num1
arithmetic endl: <<endl;
are:
"<<
<<
num num operators.
30 +=
30 "<< <<
assignments. num3
and ="
30
and
num2, are: is is relational
* *4 +4
<<endl; num3 the applying
applying 16 20
multiple implement = =
to
numl, and is is implement
t4 +4
<<
num3 num2,
perform after after ng applying
5*6:assigned applyi
numl, to num num <iostream.
h>#include
num3; toa
after program
num3= .h>
<iostream
#include
to #include
<i0stream.
h> program of of after
<<num2
<< to
program num2, Values "value"Value
assigned
=
operators. numnum
num2
a int
num=4; int
main)
main)numl, int
main) *4:
num << +4;
num<< 0return
;
a int 0;return
Create of of Write
Write =
cout
<<
Output: values cout cout
Output: valueValue
intnuml
Q24.
022. Q23. { Ans.
Ans.
numnuml<<
endl;
operators. numl-num
<<
endl; aii operator
endl:
:
endl
operator.
<< :
endl otsrolb assignment 1S
arithmetic numl num1/num<< operator
3is
is4 << assignment
+ <<
numl/num
increment num
increment
<< " applying
the is gnment
" <<
<< is
all
to
program <<2 the
post implement " 5*
is 2 is is"
assi
pre
of5- implement after
5 2 10 applying
applying
applying 5 / of
+ 5%2Multiplication is
2 3 num
4 of Subtraction
of is 2
is of 7 2
h> int
num=2,
num1=5;
Addition 2 is * to of after
num . Division is 5- 1 5 #include
<iostream.h> num
<<
endl;
2 after
after <iostream Modulus /2is program value
is 5 of
of + 5%2 num
numnumnum int
main
() of 5 Multiplication
value <<" 2 The
" <<"
" return
0; of Subtraction
of of
of of of a #include << << << of a int
main()
VWrite int return
0;
num; Cout
Chapter
2 value
ValueFinal
Value coutcout
coutcout cout Output: Addition
Division Write
Modulus <<
num=5;
lue
Output: va
Q20. Ans. } oQ21. The
Ans.
118
º
Grade A
prate
Output:
return
0;
endl; << Grade
<75)n
sula cout
A <<
o markS Il 65
(marks> if
{
else
<cendl; Grade
" B <«Cout }
60) marks< && 50(marks>
marks=70; int if
mainO int
<iostream.h #include
operators. logical
implement program Ans.Be
to Writae Q25.
vote Eligible
to
Output:
return
0;
endl: vote"
<< eligible
to "Not <<cout
else
endl; <« vote "Eligible
to <«cout
>18)ng (age 1f
18; =age int
Chapter2 120