Programming Reviewer
Programming Reviewer
-computer program is a collection of instructions that performs a specific task when executed by a computer.
In order to write a program to instruct a computer, you need to think about each problem clearly, breaking them into
something called methods.
In able to write computer instructions, programmers use a specific set of language, called programming languages to
create computer programs.
Mnemonics are memory aids – in this case, alphabet abbreviations for instructions.
High-level languages are a vast improvement over machine and assembly language, because they allow the programmer
to use instructions that are more closely resemble the English language.
Programming paradigms are a way to classify programming languages based on their features. Languages can be
classified into multiple paradigms.
1. Structured Programming
A programming paradigm aimed to improving the clarity, quality, and development time of a computer program by
making extensive use of subroutines, block structures, and for and while loops – in contrast to using simple tests and
jumps such as the go to statement which could lead to “spaghetti code” which is difficult to both follow and to
maintain.
a. Sequence Structure – in a computer program directs the computer to process the program instructions, one after
another, in the order listed in the program.
b. Selection Structure – indicates that a decision (based on some condition) needs to be made, followed by an
appropriate action derived from that decision.
c. Repetition Structure – directs the computer to repeat one or more instructions until some condition is met at which
time the computer should stop repeating the instruction. The repetition structure also referred to as a loop or as
iteration.
2. Object Oriented Programming- More advance high-level languages can be used to create object-oriented programs in
addition to procedure-oriented ones.
an object-oriented language requires the programmer to focus on the objects that the program can use to accomplish
its goal. The objects can take on many different forms.
The following are six steps in the Program Development Life Cycle:
1. Analyze the problem. The computer user must figure out the problem, then decide how to resolve the problem -
choose a program.
2. Design the algorithm. A flow chart is important to use during this step of the PDLC. This is a visual diagram of the flow
containing the program. This step will help you break down the problem.
3. Implement the algorithm. This is using the language of programming to write the lines of code. The code is called the
listing or the source code. The computer user will run an object code for this step.
4. Test and Verify Program. The computer user must debug. This is the process of finding the "bugs" on the computer.
The bugs are important to find because this is known as errors in a program. One must run the program to make sure
there are no syntax and logic errors. Syntax are grammatical errors and logic errors are incorrect results.
5. Maintain and update the program. This step is the final step of gathering everything together. Internal
documentation is involved in this step because it explains the reason one might have made a change in the program or
how to write a program.[7]
The output is the goal of solving the problem, and the input is the item or items needed to achieve the goal. When
analyzing a problem, you always search first for the output and then for the input.
An algorithm is a step-by-step instruction that accomplish a task. It is an English-like way of writing and expressing a
solution to a problem. An algorithm helps construct the actual program easily and clearly because it is like a blueprint of
a program, it served as an effective guide to our programming tasks.
The word pseudocode means false code. It’s called false code because although it resembles programming language
instructions, pseudocode cannot be understood by a computer.
a flowchart uses standardized symbols to visually depict an algorithm. It is the graphical representation of a program. A
flowchart shows the logical sequence of instructions which a computer has to follow. The major uses of flowchart are in
program documentation and program presentation.
The flowchart contains different symbols which are connected using lines, called flowlines.
compiler which scans the entire program and translate it as a whole into a machine code for the computer to
understand.
The instructions you enter into an editor are called source code.
Many C++ development tools contain both editor and compiler in one integrated environment, referred to as IDE
(Integrated Development Environment). Examples include Microsoft Visual C++, Borland C++ Builder, and CodeBlocks.
C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. It runs on a
variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
As mentioned before, C++ is one of the most widely used programming languages. It has it's presence in almost every
area of software development. I'm going to list few of them here:
• Application Software Development - C++ programming has been used in developing almost all the major Operating
Systems like Windows, Mac OSX and Linux. Apart from the operating systems, the core part of many browsers like
Mozilla Firefox and Chrome have been written using C++. C++ also has been used in developing the most popular
database system called MySQL.
• Programming Languages Development - C++ has been used extensively in developing new programming languages
like C#, Java, JavaScript, Perl, UNIX’s C Shell, PHP and Python, and Verilog etc.
• Computation Programming - C++ is the best friends of scientists because of fast speed and computational efficiencies.
• Games Development - C++ is extremely fast which allows programmers to do procedural programming for CPU
intensive functions and provides greater control over hardware, because of which it has been widely used in
development of gaming engines
• Embedded System - C++ is being heavily used in developing Medical and Engineering Applications like software for
MRI machines, high-end CAD/CAM systems etc.
Code::Blocks is a free, open-source cross-platform IDE that supports multiple compilers including GCC, Clang and Visual
C++. It is developed in C++ using wxWidgets as the GUI toolkit. Using a plugin architecture, its capabilities and features
are defined by the provided plugins. Currently, Code::Blocks is oriented towards C, C++, and Fortran. It has a custom
build system and optional Make support.
• The C++ language defines several headers, which contain information that is either necessary or useful to your
program. For this program, the header is needed.
• The line using namespace std; tells the compiler to use the std namespace. Namespaces are a relatively recent
addition to C++.
• The next line '// main() is where program execution begins.' is a single-line comment available in C++. Single-line
comments begin with // and stop at the end of the line.
• The line int main() is the main function where program execution begins.
• The next line cout << "Hello World"; causes the message "Hello World" to be displayed on the screen.
• The next line return 0; terminates main( )function and causes it to return the value 0 to the calling process.
A block is a set of logically connected statements that are surrounded by opening and closing braces
A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item.
Whitespace is the term used in C++ to describe blanks, tabs, newline characters and comments. Whitespace separates
one part of a statement from another and enables the compiler to identify where one element in a statement, such as
int, ends and the next element begins.
There are following basic types of variable in C++ as explained in last chapter –
Variables that are declared inside a function or block are local variables.
Global variables are defined outside of all the functions, usually on top of the program. The global variables will hold
their value throughout the life-time of your program
C++ comes with libraries which provides us with many ways for performing input and output. In C++ input and output is
performed in the form of a sequence of bytes or more commonly known as streams.
• Input Stream: If the direction of flow of bytes is from the device (for example, Keyboard) to the main memory then
this process is called input.
• Output Stream: If the direction of flow of bytes is opposite, i.e. from main memory to device (display screen) then this
process is called output.
1. iostream: iostream stands for standard input-output stream. This header file contains definitions to objects like cin,
cout, cerr etc.
2. iomanip: iomanip stands for input output manipulators. The methods declared in this file are used for manipulating
streams. This file contains definitions of setw, setprecision etc.
3. fstream: This header file mainly describes the file stream. This header file is used to handle the data being read from a
file as input or data being written into the file as output.
The two keywords cout in C++ and cin in C++ are used very often for printing outputs and taking inputs respectively.
These two are the most basic methods of taking input and printing output in C++. To use cin and cout in C++ one must
include the header file iostream in the program.
Standard output stream (cout): Usually the standard output device is the display screen. The C++ cout statement is the
instance of the iostream class. It is used to produce output on the standard output device which is usually the display
screen. The data needed to be displayed on the screen is inserted in the standard output stream (cout) using the
insertion operator(<<).
An operator and any of its operands taken together constitute an expression. Such expressions produce a result that is
the effect of the operator on the operand(s). They are classified based on the types of operators they contain.
• An arithmetic expression contains arithmetic operators, gives a numeric interpretation to the operands, and produces
a numeric result.
• A string expression contains string operators, gives a string interpretation to the operands, and produces a string
result.
• A logical expression contains relational and logical operators, gives a logical interpretation to the operands, and
produces a boolean result: TRUE (1) or FALSE (0).
C++ programming language provides following types of decision-making statements.
1. if statement An ‘if’ statement consists of a Boolean expression followed by one or more statements.
2. if...else statement An ‘if’ statement can be followed by an optional ‘else’ statement, which executes when the
Boolean expression is false.
3. switch statement A ‘switch’ statement allows a variable to be tested for equality against a list of values.
4. nested if statements You can use one ‘if’ or ‘else if’ statement inside another ‘if’ or ‘else if’ statement(s).
5. nested switch statements You can use one ‘switch’ statement inside another ‘switch’ statement(s
• The expression used in a switch statement must have an integral or enumerated type, or be of a class type in which
the class has a single conversion function to an integral or enumerated type.
• You can have any number of case statements within a switch. Each case is followed by the value to be compared to
and a colon.
• The constant-expression for a case must be the same data type as the variable in the switch, and it must be a constant
or a literal.
• When the variable being switched on is equal to a case, the statements following that case will execute until a break
statement is reached.
• When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the
switch statement.
• Not every case needs to contain a break. If no break appears, the flow of control will fall through to subsequent cases
until a break is reached.
• A switch statement can have an optional default case, which must appear at the end of the switch. The default case
can be used for performing a task when none of the cases is true. No break is needed in the default case.