Horizontal Nav

Monday 27 July 2015

Standard Input/Output in C++



The standard streams are pre-connected input or output channels between a computer program and its environment (typically a text terminal) when it begins execution.

Standard Input (stdin):
Standard input is data (often text) going into a program.

Standard Output (stdout):
Standard output is the stream where a program writes its output data.

Types of Code in C++



There are two types of codes that are as follows:

Source Code:

A program written in a high-level language is called source code. Source code is also called source program. Computer cannot understand the statements of high-level language. The source code cannot be executed by computer directly. It is converted into object code and then executed.

Object Code:

A program in machine language is called object code. It is also called object program or machine code. Computer understands object code directly.

Monday 13 July 2015

Errors in C++

Debugging

An error in a computer program is known as bug. The programmer can make different errors while writing programs.
The process of finding and removing bugs is known as debugging.

Run Time Error

A type of error that occurs during the execution of program is known as run-time error. It is caused when a statement directs the computer to execute an illegal operation such as dividing a number by zero.
The run-time errors are detected and displayed by the computer during execution. Run-time errors are normally caused due to wrong input from the user. The computer stops executing the program and displays error message if a run-time error occurs.

Example: 
The user may ask the program to open a file that does not exist. Similarly, the user may enter wrong type of data etc.

Logical Errors

A type of error that occurs due to poor logic of programmer is known as logical error. A logical error occurs when the program follows a faulty algorithm. A statement with logical error may produce unexpected and wrong results. For example, the programmer may have written a wrong formula to computer an answer. The formula will be executed without any error but will produce wrong results.

Program Flowchart and Compilation

Program Flowchart

Flowchart is combination of two words flow and chart. A chart consists of different symbols to display information about any program. Flow indicates the direction of processing that takes place in the program.

Flowchart is a graphical representation of an algorithm. It is a way of visually presenting the flow of data, operations performed on data and sequence of these operations.

Program Compilation


The process of checking the program for errors in order to execute it properly is called program compilation.