You are on page 1of 12

an in

construct, type of classes,


and the program
into
binary
Basics within of
99
C++ bits
type for
construct of
same
encdosed (alias) individual part
oitesst0 E9
specitic data the another
variable.
one
data functions,
name holds
character a from
some define new the
secondvalue. which operand.manipulate
operands. k
a as control program.C++
to create
singie represent any you of of such C++.
e
a
return each address
constants. single transfer a
a provides allows you
types. two to elements, C++ of
have in
or helps locations, operator code
not data location. a with you
memory output.
that store that integer on allow that a
that does that workwork of source
typedifferent various egon
constantsto storage statements point
variable memory arithmetic
used thatdata type named the thatthatthat the
stores of
operators entry the
type of data data operators
operators Falselt display
the identifier user-defined collection
a data variables
same
of
user-defined compiles
to that the the
to program. set of the
Refer Refers a thea collectionvariable to to to
of to to Refer loops. denotesis used
an
to
already
existing
variable.
Refers the share Consists ReferRefer a
to
Refer ReviewN
Exercise functioncompiler
constants: a
to a variable: to store a Refer statements: nest is
within a operators: another.
to
program
Refers Refers to members a to operators:
operators: printf
quote.
single
a type: to Refers sign
to Refers Enumeration:
Refers Namespaces: cannot main()
information
Reference
helps C+t
Character dataStructure: ++ C++,
Variable:
all Pointer: Bitwise and
Union: form.
void
which which Array:data.
of UnaryBinary values. structs.
Jump We False TheFalseTheTrue The TrueIn False
True
Q1. Ans. n Ans. Q3.of
Q2. g tAns. l Kolonn
oQ4. Ans. Ans.
m O O O Q5.
sb
bns
. dad fractio that
a funcand
neither ah
sof abe dats Ne learned tunct perform spe fractional
exit()
successtully abot structure
learned
and operators,
a
variables, perform program.
data of valhold that
ues
is functio have to executton.
complie fractionalconsist
country
and
the learned variables, executable
file. used respectively. no
the have you to digits,
executed
that exit() and statements. it. to written C++ the that
are program
a executed.
gets the haveaboutyou constants,Finally,
directives,
in
data gives of
of which a by constantsconstantsS
value is Use Then, in ignored onlyconsist
youlearned an particular operations,
program
into is files
jump
programming. programmer code interrupts modified.
program to , of
the program First, program.
identifierS, and header that
preprocessor
and the is consist
the
the
If have which
e. default
then
the
basics.
loop, store *, division
where C++. be
constants
to
to
is your you , include
which that Refer
value the C++conditional, a in program, cannot Refer
in C++Next, keywords, a to that +, program names constants
file execute of variable as to condition, constants:
countryindicates header about casting,
in code
or
multiplication,you the constants:
e, background. namespaces names such that
to decimals.
reserved
a
or stdlib.h learnedandas type includes source a symnbols, a Allows in theRefer
values
the 0 such to of unwantedtext point
typethe to large.
wheni, ofvalue the
compile
C++, discussed the
part Directive: constants:
thethe fixedRefer exponent.
containing
point
C, havehistorical of which a to and to subtraction,
a floating
displayed AssignsConstants,
Converts classes. to to too
values-a,
specified
return
The
include role Refers Refers to an Refers
Refers
to constants:floating or
you to of Terms
Key Refers for Refer
programmers.
must
Summary howcomponents
alsothe structures, to
Preprocessor
Refers pointan values small
Constants:contain Exponential
chapter,
its types: Comment:
terminated. and about Compiler: ldentifier:
Operator: Function: Keywords: Fractional too
is You and chapter addition, Floating or
2 Englandcalled.
Chapter is program Error: Integer values either
thisC++ learned
control Data task.
basicThe also
In of O OO O O 0 O O O O O O
98ºe
not specific memory
acreate
C++
Basics
101
data
constant?0 types?
a
represent to same
the you data
Directives
Preprocessor
of compiler? modified? helpsthe existing
hiding share
Polymorphism or Enumeration
d.
storele type
allows Inheritance the Comment be
d.
Variables Constant
d.
Variables
b. Character
d.
Boolean
b. d Identifier
b. which membersStructure
b. from Derived
ob.
function? by cannot to program?nilioh
Void
d.
ignored used
created
OOP of types,
b. d.
specific b. value category d. the
of is is
is token's tokens user-defined
all types
features tokens
a a which
perform not a
following data
following following within
following is
following in following
Questions
Choice
Multipleto Dataisc.
Abstraction b. d. b.
is information a.
following
construct C.
is
b.
is
user is is is
option
option
Encapsulation the optionthe option Pointoption
Floating the option option
User-Defined
the of Data
types the
a
by
one
of ldentifier
Constant of Operators
Comment the
out Variablescorrect thedata
of correct correct
one of Integer correct
correct location? Unioncorrectof Built-in
a. correct
required
Which of
Which of Class Which
Which Which Which new
The The The The type The Out The The
C. C. C. C
d
Ans. Q3.
d
Ans: Q5. o Ans. Q6. t Ans. Ans.
s Ans. Q2. Ans. Q4. uldaney
giver tevaluates complewhen
o statements r
variablk in ina conditioh
aC++
program. declared code date,
the
a
as
snoindo
initialized.
program. of the the wvalve
iatax not from
use are block
until condition
processes or
exit
they whether
cannot aat a
invalues once C++ execute code to
where while
aloop
ok modifieda of input, until need
you in
constant
define
helps constantlocation to block on
in
which condition as code
depending body we
be a data
execute its
C++
words cannot a the
function. declare takes in
$ymbol on a are
required
specifies
that depends ly
to repeated program output.
The ios
preprocessor
#define executes
name. the values used
an reserved statement false.
have variables required executes The goto
statements
is is statementsain
keyword function fixed keyword
false.
evaluates
to if or
statement
can data true
are are
identifier C++
program.
of conditional the nested
loops.
The Keywords
endI a Constants of is
or const scope program.Iteration flow generates condition
False name
2
Chapter True True An False True
Ans. The True The TrueAns. True False The True
Ans. Q16.
The True true.True True
A A
Q6. Ans. Q7. Ans. Q8. Ans. Q9 Ans. Q10. Q11.
Ans.
Q12. Q13. Q14. Q15. Q17. Ans. Q18. Ans.
Ans. Ans. Ans.
º
100
103 a
C++
Basics initialization, a unconditional An words,are of
of of Some
file. There
statements termination other download.
executable
format.
loop? In
parts: an code.machine-readable
different a perform an to
-until
repeat
b. immediate
of
three intosource free follows:
C++4? out code?
to if-else
b. do-whíle
b. do-while
d. program are
control
switch
d.
condition? in d.while jump break of break
d. to break
exit
d. Ct the whichas
valid to exit
b. consists
expression? causes exit
b. usedthe in of are
used Sd. in a formintoInternet,
C+t.terms compilers
is statement
b. of
transfers not
statements program
codebinary
a
of is is statements functions in used
value constructs statements source
usedcommonly overC++
post the
statement another commonly C++available
the and following the ofconsists used
iteration following Short
Descriptive
Questions commonly
on following following expression,
to
Convertsaconverts
some compilers
ladderis
d.option
if-else
depending c. d. a. a. C.
015.
Which
conditional repeat-until
is is is is control is
terms file
option option option option option are
the the the following compiler
executable
Compiler:
thefor-loop the for-loop Continue most
Various
conditional the
program correct
The
of
correct
of
correct
of correct
while of oftransfergoto
of program? correct correct
quitend Explain the
Which Which Which Which abortend Which
1f
The 2nC.
The The The The The
O
a
gs
a. C. a. C. a.
o16. o17.
a.
Q18. C
Q19. Q20. Q1, Ans.
pein
Ans. Ans. Ans. Ans. Ans. Ans.
construt te
vara
staateifexecuted
men
fil
a
include
the
of
of are control0
Flow
data size that
operand? alternative
the is
a
define Enumeration
to Unaryoperators
b.operators Special
Operators
d.
Operators
Binary Special statements
operators
d. d.Jump statement,
following
conditional
statements statement
adder
b. helps Shift
b.operators
calculate
1
single
to types? Union b. #include
#define
directives Special an b. 1f-else
f-else
you as to
iteration
another
a
data
allows on works used
d. d. works operatorsed.
different b.
and b d.
preprocessor is and
types operators
operators
operators program?
conditional true
dataof
variables variables? is
following following following
following following aof
the
condition
a. d. b. Operators
a. d the execution isb.
is is C
Ternary
operators C
Format
specifiersof b.
is is a
Binary
operators
is is
storing option option Shift
a.operatorsoption Shift
Operators
option global call
option option
a.Manipulators hich condition
is
false. option
the Structure theC++ program? the
correct #undef #pragma the Ternary the Ternary the you
of in of correct
of correct
of
statement?correct access correct the correct if correct
Which
helps Class of do using
executed
Which Which control
2Chapter
102 Which which 1f
The The What The
The The and The The By
C. c
Q8. C
Ans. Q9. Ans Q10. Q11. Ans. Q12. Ans. 13.
lea Ans 914. Ans.
Ans
105 by
C++Basics for a avalue including
the in addition,
various C++ an variablecontain data cannot the will of in of
given written
within stored
in
of
quotes.
single specify
variable typebytes
amount categories:
size constants.of
constants the also you data4
dlasses information as functions in
as The categories
as to a the long utilize
are suchstored
according
to such data.with can language,
useddata broad
and Comments The
real specifies
operations
the
operations, used
fractional data;as in main thecan
constants, values enclosed is of long following
modified. known typekind example,
of utilize type fractional programming
type the also
changed. variable perform
compilers. the no data datathe type
functions, can perform also characters name the
specify
specific on be
constants? and are term Forof into
you integer are
categories:
cannot digits of What data.variable
anyTheto variable divided
be type
aof division constants
youthat to Consist single
variables,the cannot represents used have store
only types? of
by Helpsso of thatmajor the partthem. a ais, be
program or
executedthat Specifies
the
are values of on
categories pointconstants:
constants:Contain we to
with that
means utilize can
store. important
without
the Directives. thatmultiplication, followingConsist
depends data
values
and fixed floating used bytes, C++ User-Defined
data
types
of to C++ by
Names code. Stores Symbols which
wants various
are
constants:
mean veryvariables typecan 4 in types Derived
typesBuilt-in
data data
types
a Not the Fixed
programmer. a
in
Preprocessor
into constant
point The variable
of
programmer C++ variable,
Identifiers: describing
Comments Constants: types filesfiles.
header subtraction, divided
Operators: exponents.
Character a data sizeData
Variables:
program. the
variables. youC++?
in
typesare
in Integer
Floating declare
header integer do types The a a memory.
O
Data are Constants name. has
memory
of
What be What Data eventype Store. Ctt
can
O O O O O
Q4. Ans. Q5. Ans.
perfo codedefine C+s program syntanin
a you then error in the te
tastlengtho s
data variah a wrongint and hand,
programmer's of simplity incluoeu coueSou
incluoe r
it A logical length file Sp ie
in to thefunctions in theerror. writing understand
mistake. theother sourcethe files. meaningrui white
C++
valueto
particular
used
executable
grves write files something not can be to with header
interrupts calculate by in
integer many header logicalof error thethe mustneed with available
areoperations. instead programmer's you
calculate file separated
store programmerwe a On that youfile header with are
that where cannot simplify programs, generate
oniy of andwritten syntax to code. this code and are C++.
to / consistincludewhich example, program filesobject,
programs.
compiler
variabie
store error compiler to link are
library
division
program detect that the used other the to source that in
have to C++? tokens used
can a . may to condition, syntax a write
C++ coutNow,linkused
Tokens
a int that as or For onlydue functions create function various C++
C++ to program you you a occurs in your theprogram. to the C++, terms
in are
GNU type such the
multiplication, types: read. which
can linkers to functions processlinks the lines.
type names Allows unwanted when to needs in use in
that
classes. of compiler + wants libraryerrors In
which in tokens.
reserved
is a data symbols,
partA two cannot which C+
variable, to
stored
C++ Compilers predefined
new
Turbo
C/C++ thatassign the
compiler task. Directives: program and predefinedprogrammer example, The
Borland
C++
compiler of and of compiler error, programmera library
of
your linkers, and
compilervariable a functions is are
chance or
to specific
file.
to to to subtraction, an is a C++ function as
C++? known tabs,Predefined
constants,
Used Refers Refers Refers aby to
error
a
declarean Using functions linkers.
Forin executable
programmer. A is are the file have are blanks,
Linux/Unix
example,
a Refers
some Preprocessor in a
An occurs occurs. the program. in
types: that errorlibrary
functionsstrlen) header thatare
tokens
to a also
Operators:
ldentifiers: Functions: execution. if then string. reduce
library
by
functions, perform progranm. program
addition, INTerrorlogical example, done code
elements
compiler
Keywords:
include
Errors: an
Data error write are and C++Iostream.h are
the specified
º For an Librarystring. C++, produce
is source
A What C++, work your code What which
04>
Chapter
2 For TheC++
D O O O a In O
Q2. Ans. Q3. Ans.
sizeof in The
special operators. special Known
as compiler
operator, are Ct+ operators preprocessor
han that includes
a C++ compiler.
The C++
global accessing variables
and of the
size calculating Such
as before handled the
variables
are code the are directives Preprocessor constants.
functions, types
of various perform operators
toused Operators:
The Special O passed is define
header
files stored
in functions
operations
such the utilize so C++ ain
operands. including as perform can you you heldipthatrectivprogram
esPreprocessor
three onworkoperators Theseoperators. ternary known
as Statements are header f Ans.
if-else alternatives
the of work that
as operators Operators:
The Ternary ona dbiey
directives?eco preprocessor are What Q9.
operators. (<<) shift left and (>>) shift right supports C++ value. used. being
integral an be should operand operators.
The shift called aroperand
e the declared beto needs and C++ variablesin other to
similar pointer
right
of orleft pattern
to bit the shift tousedoperators Operators:
The Shift O bet another
Va address
of memory the stores that variable Pointers:Ais
operators. bitwise operators,
and data. typeof
logical operators., relational operators, assignment arithmetic operators, thesholds which of
locations,
each storage data collection
of Arrays:
A D
ssignment operators, arithmetic operators
are binary the Some
ofoperators. in
C+*.available are that types data derived the following
are
binary called operands
are two onwork operators
that Operators:
The Binary Thetypes. data
detoula knownas are types dataexisting from created becan that types data The Ans.
variable. constant
or types?
a becan works operator unary which
a operand
on operators.
The unary dataderived bymean you do What Q8.
called operand
are single aon
work operators
that Operators:
The Unary take. can type that
C++are: operators
in various variables.
The variabe thata values the names
to provide toyou Allows
Enumeration: O
various stored
in values the on
based division multiplication,
or subtraction, location. memory
addition, operations,
as
such perform toused are thatsymbols Operators
are sns. a san the sharemembers all which construct
in data
Creates
a new
Union:
uoyo C++? operators
in by
mean you What
do Q10. types datdifferent
a
h
variables store helps whicconstruct, data defining
a if Al lowSStructure:
macro defined Undefines
the #undef : da
the on
work (functions)
that code (variables)
and data Consists
of Class:
code
the ofrest the before runs that
function special Represents
the #pragma: C++: create
in can you that
directive line current Represents
the #1ine: user-defined
to
data the following
are The types. user-defined
data create
uniare on and struct to
program C++ the infileincludea #include:
Heltops askeywords,
such C++ Some types. user-defined
data as
directive
if-not-defined Represents
the #ifndef: kn atypes
re data These types. data Own your use and create can you C++ In Ans.
macro 2 types? user-defined
data bymean you do What Q7.
existence
aof the test touseddirective if-defined Represents
the #ifdef: Void
statement ifthe similar
to works which directive Represents
ifthe typeBoolean
#if: O
messages error tcompiler
ime Produces #error: type poinFloating
t O
statement else the similar
to works directive
and elsRepresents
e the #else: type:
Character O
aldeiey
else-if the similarto works thatdirective else-if Represents statemnent typeInteger O
the #elif: in data built-in the following
dharan C+44*the totypes datainteger and
macro/token Definesa#define: types applied short, long,unsigned, are signed, The types. such
asmodifierS,
standard
C+ -in several
following in
preprocessing allowed the are known
basr h asdata built- all type, data void the Except types. fundamental
data
The starts. process
compilation+ directives C++ the beforedirectives Renrocessor also are which types aldatabuilt-in
supports compiler C++ The Ans.
107 Basics
4 C++ types? databuilt-in by
mean you do
What Q6.
Chapter2 106
false; a= bool conditional and loopss from exit statement:
toUsed break O
statemen
{ supported statements jump following
the are another.
The program
to
main) int by
C+t transfer statements
that are
thestatements Jump Ans. 2n
part one from Control
<iostream
.h> #include of C++. supported
by
the bewil What jump List
thestatement? jump the by
mean you do What Q15.
program? following the output
of Q2. stateme
expression post expression
and conditional initialization, such
as
45is:numbers two the ofsum The and times number
of fixed overaIterates loop: tor D
of
threer consists
35 loop. while
10
numbers: two Enter Out
comesexecution flow
of the false,becomes condition the
the of statements group
of executesa condition.It
The condition
b the long
as as
follows: program
asis preceding of
the output Ans. checoT then and once least atcode Executes
the loop: do-while 6200ot
O
terminated. gets loop the false,becomes condition the Once
Executes loop: while Obalso ed
return
0; evaluates
to condition until its in
a body statements
cout<<"The
C++: supported
by statements iteration the of
list thfollowing
e is The Ans.
"<<sum; is:numbers two the of sum
num2; numl+ sum= enu C++. supported
by statements iteration the List Q14. bolle
cin>>num2;
ci>>numl; loop. thefollows statement
that next the transfers
to control the that,
endl : numbers:
"< cout<<"Enter
two exits.A
, loop thefalse, evaluates
to expression conditional the Oncecondition.
sum; num2, numl, int basedor code of
block executea repeatedly loops statements
or Iteration Ans. b
main() int TadW09 statements?nn
bue iteration by
mean you doWhat Q13.
statement switch Nested O
#include<iostream.
h>
statement switch
program? following the output
of the bewil What Q1. ladderst
e iooo if-else D zlosit
Problems Practical statements Nestedif o
statement if-else
error. indicates
an
AILURE EXIT value
of return whereas,atermination; suCcesstul indicatesa statementeoinb
ioo if
CCESs EXIT or 0valueof return The value. returnsa alsfunction
o exit) C++: supported
by statements conditional the oflist tfollowing
program.
The
he is The Ans.
C++ terminatea is exit)
orend toused function thwhereas,
e
ments, conditional and loops from exit toused statement
C++. supported
by statements conditional the List Q12.
is break The Ans. is
code accompanying
ock
blof the false, is itexecuted
aif
nd
exit statement? expresaCCompanying
ibypassed.
on. blofock the true,
the statement
and break between
the difference the
beto out comesexpression conditional
What
is o16 statementf sconditional evaluating
a code
programs C++ end statements:
Used
to abort on of
block executea program
to
and exit cbhetoose Conditional program. paths execution
a in
code thstatement
e in another more ortwo
conttorol transferunconditional
of perform toyou allows that
statement control a
statement
is conditional
an ed
toUsstatement: goto n
AAns.
begin and loop current iteration next executing
the derefopeerarencing statement? conditional aby
mean you doWhat Q11.
the iteration
of quit
tostatement:
Used continue n operators. management memory and
109 Basics C++ (SRo), operator resolution scope operator, comma
Chapter2 108
numbers.
num c< "is: numbers.
num the value
of The <<Cout
15 is: num3 of
value The 10.2665 : numbers.
num
tollows program
asis preceding of
the output The Ans. numbers; example
num2 double
is:"<enum3: num3 value
of TheCout<< num: double
um2; num3=num
1&n
num247; example union
numl=31:
num3; num2, numl, int mainO int
main) void <iostream.h #include
program?a following the output
d Bie sdsahe
ed it pnleolloh
#*include<iostream.
h> of the be
wil What Q4.
program? following the output
of the bewil What Q6. 22student
is the number
of rol1 The
standard. 8 instudent
is The
30 : is Multiplication
3and 10 of
7osa :is and3 Subtraction
10 of follows: program
asis preceding the of
output The Ans
13 : is and3 Addition
10 of
folows: program
asis preceding the outputof The Ans. return
0:
<<endl: num rollJohnny. is
<< student the number
of rol1 The <<cout
standard."<cendl; standard<e" Johnny. <« "instudent
is The <c
cout
return
0;
endl; << Johnny.roll_num=22:
mu:<<
l is <<y < and" <«" "Multiplication
x of"
<< <<cout
Johnny.standard-'8':
<su:<<
b y<«ís <« and <«" x <<"Subtracti
" of on endl; <<cout
Johnny: student
<<sum is <<
<<and"
y << x <<Addition
of endl; <<cout
y; * x =mul lsaitaeamslcio19 rol1_num; int
y:x- sub= standard: char
y; + X =Sum
mul: sub, sum, 3, = y10, = x int student struct
main() int
main) int
<iostream.h> #include
program? following the output
of <iostream.
h> #incTude
the bewil What Q5.
program? following the output
of the bewil What Q3.
10.2665 numbers.num2
is: the value
of The
10.2665 1s: numbers.
num the value
of The variable
0is: type boolean the value
of The
follows: program
asis preceding the output
of The Ans. follows: program
asis preceding the output
of The Ans.
end1: num2< numbers1s:«
. numbers. return
0; return
0:
num2 the value
ot "The
111 Basics C++ Coutc is:"cca variable type lean boo the value
of The <<cout
Chapter2 º110
25.12 macrofunction
is Value
of
3.14 is p of
Value is:"<1<e variable return
0;
timesi shifted5 right Cout<e"The
value
of
program preceding the output
of The Ans. "<i<<end1 : is: iof 1>>5;
valcout<<"The
ue i
follows: asis
180; i
return
0; i; int
value
of <«" Cout nabuta
endl: result
<< is function
<< "macro
circumference
(4): result
= main) int
endl: << p<< " is pof
value <<"
result; double cout <iostream
.h> #include
PI; double
p= program?tuh following the output
of the bewil What 9.
main() int
Sl livu sdsrituctuo6ollald
lo variable
is i value
of
(2*PI*a)circumference
(a) #define 5variable
is j of
value
3.14 #define
PI
<iostream
.h> #include follows:2E program
asis preceding the output
of The Ans.
program? following the output
of the bewil What Q11.
=U value Fourth endl; return
0;
<< i i: << "variable
is i "value
of <<cout
U
value= Third endl; <« j << "variable
is j
=Uvalue Second "value
of <<cout
A
value= First
j=1++; int
follows: program
asis preceding the output
of The ()main int
Ans.
5; = iint
return
0; <iostream.h> #include
end]:TSy s c<
value4 <<
-" value "Fourth <<
cout program? following
end]:ts value3
<< << value
" = "Third <<cout the output
of the wil What
be
endl: value2
<< <«=" value "Second <<cout Q8.
endl: valuel
<< << "value "First <<cout e0
'u': value4= value3= value2= 115.459999
value4: 'A':; valuel= follows: program
as is preceding the output
of
value3, value2, valuel, char The Ans.
{
main) int tel uoto
i d52 endl;ollot io sr return
0;
iuth <iostream.h> #include <<num <<
cout
program? following numl+num2+num3); num3, num2, =(numl, num
the output
of the bewil What
num3=35.b6isuee
Q10. num; float
variable
5is: timesi num2=23.25, numl=56.55, float
shifted5 right value
of The
{
180 is: i of
value The main) int
follows: program
asis preceding
113 Basics C+ the output
of The Ans. <iostream.
h> #include
program? following the output
of the bewil What Q7.
Chapter2 º112
a
C++Basics
115 of
members
the
<<""<
endl:
total.Java
<<""<
endl: all
endl: that nslormego
« showing
<< total.DBMS location. endl;
endl;
total.cpp union
<< <<
a memory
create pdt ue.y
value.X
<< << are"
<<
snebt
are" val
are to << <<
JavaDBMS
same
program
CPP value.x="
="
<iostream.
#include
h> value.y
50 55 53 the x:q
int int
DBMS;
Java; in in "Marks
<<
in
cpp;
int 55:53:
DBMS=
total.
Java=
total. "Marks
"Marks areareare to
50;
total.cpp= C++point int
y;
total;
marks Cpp Java
DMS check
unionint check
value;
value.X=
5; <<" 5 Value.y
=
5
Value.X
=
<«" return
0;
0;return a int
main()
« K in in in
Output: Marks Writeunion aeitb Output:
coutcout
cout Marks
Marks CoutCOut
} Q15.
Ans.

};
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

You might also like