0% found this document useful (0 votes)
775 views

Last Minute Revision Notes For C++Programming Exam

This document provides revision notes for a C++ exam, covering topics like flowcharts, algorithms, conditional statements, loops, operators, classes, inheritance, pointers, exceptions, and file handling. It includes brief examples and explanations of each concept, but clearly states that students should study each topic in detail from other materials, as this is just meant as a last-minute revision and not a comprehensive guide. Key concepts are summarized, but in-depth learning of C++ is directed towards other sources.

Uploaded by

Ajeet Bharti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
775 views

Last Minute Revision Notes For C++Programming Exam

This document provides revision notes for a C++ exam, covering topics like flowcharts, algorithms, conditional statements, loops, operators, classes, inheritance, pointers, exceptions, and file handling. It includes brief examples and explanations of each concept, but clearly states that students should study each topic in detail from other materials, as this is just meant as a last-minute revision and not a comprehensive guide. Key concepts are summarized, but in-depth learning of C++ is directed towards other sources.

Uploaded by

Ajeet Bharti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED

ON MOODLE

Last Minute Revision Notes for C++ Exam

1. FLOWCHART

For flowchart, just remember these symbols and go through the examples which demonstrate how to
use these symbols in a program. Don’t mug up the flowcharts given here as example. Just
remember the symbols. Like (if statement, while loop etc execute on basis of a decision (true/false), so
we use diamond symbol)

A simple Example:
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

Another Example (if statement)

Another Example (While Loop)


ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

2. ALGORITHM: To write an algorithm, you just have to write the steps given
in flowchart numberwise.
1) START
2) Declare Variables fterm, sterm, temp
3) Initialize the variables: fterm=0, sterm=1
4) Is sterm<1000? If yes, then execute steps 5-9, If no, GOTO step 9
5) Display sterm
6) Temp<-sterm
7) Sterm<-sterm+fterm
8) Fterm<-temp
9) STOP

3. Using IF statement
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

4. USING IF-ELSE

5. SWITCH CASE

Switch Case example ahead


ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

6. FOR LOOP
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

For loop example

7. WHILE LOOP

Example of while loop


ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

8. Operators:
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

Relational Operators:
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

LOGICAL OPERATORS
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

Variable declared outside of main() is accessible to all functions (so called global variable)

BITWISE NOT (See ppt shared on moodle)

Declaring Strings
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

9. CLASSES AND OBJECTS


Simple example (how to create a class and use it from main function)

ANOTHER EXAMPLE: CREATE A CLASS TO FIND GCD OF TWO NUMBERS

CREATING A MEMBER FUNCTION IN CLASS


ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

CONSTRUCTOR
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

EXAMPLE:
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

10.INHERITANCE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

11.POINTERS
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

POINTERS TO POINTERS
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

CREATING POINTERS IN INHERITANCE

12.VIRTUAL FUNCTION
• A virtual function is a member function which is declared within base class and is re-defined
(Overridden) by derived class.

EXAMPLE:

// CPP program to illustrate


// concept of Virtual Functions
#include<iostream>
using namespace std;

class base
{
public:
virtual void print ()
{ cout<< "print base class" <<endl; }
void show ()
{ cout<< "show base class" <<endl; }
};
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

class derived: public base


{
public:
void print ()
{ cout<< "print derived class" <<endl; }

void show ()
{ cout<< "show derived class" <<endl; }
};

int main()
{
base *bptr;
derived d;
bptr = &d;

//virtual function, binded at runtime


bptr->print();

// Non-virtual function, binded at compile time


bptr->show();
}

PURE VIRTUAL FUNCTION

• A pure virtual function is implemented by classes which are derived from an Abstract class.
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

13.EXCEPTION HANDLING
• An exception is a problem that arises during the execution of a program.

• C++ Exception handling is built upon three keywords: try, catch, and throw.

• throw − A program throws an exception when a problem shows up. This is done using a throw
keyword.

• catch − A program catches an exception with an exception handler at the place in a program
where you want to handle the problem. The catch keyword indicates the catching of an
exception.

• try − A try block identifies a block of code for which particular exceptions will be activated. It's
followed by one or more catch blocks.
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

14.FILE HANDLING
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

EXAMPLE:

Note: When you open a file for writing, then ofstream is used and when
you open a file for reading then ifstream is used.
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

STUDY ABOVE PROGRAM PROPERLY TO CLEAR THE BASIC STRUCTURE OF


USING FILE HANDLING
ONLY MEANT FOR REVISION, STUDY EACH TOPIC IN DETAIL FROM BOOKS/INTERNET/MATERIAL SHARED
ON MOODLE

eof: END OF FILE

FOR ARRAYS: REVISE THE PPT SHARED ON MOODLE PROPERLY (On Matrix
Operations)

You might also like