CPP Module-1 Notes
CPP Module-1 Notes
ORIENTED
PROGRAMMING
USING C++
1. Features of C++ ?
• Object-Oriented Language.
@RESTRICTED • High Level & English-like Language.
• Easy to debug.
6. Define Structure ?
This is the Wrong form
}
Fig of Q.7 7. Explain Structure as Heterogenous Aggregate ?
Double Datatype }; };
Hello }
Hello
14. What is Break Statement ?
Hello
Break is used to Exit a loop or switch
Syntax break ;
15. Explain While Loops in C++ ?
While Example
While loop is an Entry Controlled loop where
condition is checked first & initialization is
int count = 4; declared above loop.The updation is done inside
{ initialization;
updation;
————————-OUTPUT———————————
}
Hello
do{ initialization;
cout<<“Hello\n”;
do
count--;
{
}while(count >= 0);
//Code to Repeat
updation;
————————-OUTPUT———————————
Hello
Hello
Hello
Hello
19. Explain Switch Statements in C++ ?
Switch Sample
Switch is a used to check conditions in program.
switch( Variable ) {
break; };
.. .. .. .. ..
case 7: cout<<“Saturday”;
break;
‘;’ is not important but it’s recommended
default: cout<<“Wrong!”; just to beautify the code😘😍
};
19. Explain If Statements in C++ ?
IF Sample
If statements are used to check a condition in
int day;
program.
if(day == 1){
IF ELSE
cout<<“Sunday”; Simple IF IF ELSE
LADDER
} To check a single To Check more than 1 For checking multiple
Condition condition conditions.
else if(day == 2){
if(condition) if(condition) if(condition)
cout<<“Monday”; { { {
True Block True Block-1
} Statements
} }
}
else else if(con)
.. .. .. .. .. .. ..
{
{
else if(day == 7){ True Block-2
False Block
}
cout<<“Saturday”; }
.. .. .. ..
else if(con)
}
{
else{ True Block-n
}
cout<<“Wrong Number!”; else
{
} False Block
}
20. Explain Derived datatypes in C++ ?
Eg: Arrays,Structure,Class.
• Continue Statement
• Break Statement
EXAM • IF Statements
ONLY TO GUARANTEE 100!
• Switch Statements
cout
• cout<<Value1<<Value2<<….<<ValueN;
cin
• cin>>Value1>>Value2>>….>>ValueN;
EXAMPLE
ofstream newFile;
newFile.open(“location. extension”);
newFile<<“Message to write “;
newFile.close( );
26. Explain Common Error Streams in C++ ?
THIS SECTION IS NOT
COMPULSORY TO PASS THE clog
cerr
EXAMPLE