Saturday 15 October 2016

What is the use of terminator ?

Terminator is used to ending every statement in C++. Terminator is a semicolon " ; " put at the end of  each statement.

Rule to write a program in c++

There is not a hard and fast rule to write a program in c++. You just have to put terminator ";" (semicolon) at the end of a statement.

What is an error and what are its types ?

Error:

An Error is a mistake that occurs in a program. The error may be a syntax error,logical error or may b a runtime error.

Syntax Error:

To understand what is a syntax error firstly you have to understand that is a "syntax".
A syntax is a collection of rules to write a program in any programming language is called as syntax.

Now, what is a syntax error ?
A syntax error is a type of error that occurs when we write an instruction which is not according to the rules of programming language or when we write an invalid statement.
Example: missing terminator at the end of any statement in C++ program.

Logical Error:

A logical error is a type of error that occurs due to the mistake of human logic.

Example: Suppose you write a program to find the marks of students how has marks greater than 60. You put less than " < " operator instead of putting greater than " > " operator. This error is called as a logical error.

Runtime Error:

A runtime error is an error that occurs during the execution of a program.

Most common example of runtime error is dividing any number by 0.

What is the most difficult error to find ?

The answer is "Logical Error" because the compiler does not understand it. It only can be solved by rereading the code.

Thursday 13 October 2016

What is the basic structure of C++ program ?

Basic Structure:

Here I am going to tell you what is the basic structure of a C++ Program.
A syntax or a pattern to write a program is called as structure.
Here is the basic structure of C++ program:


Preprocessor Directives:

Preprocessor directives are included on the top of any C++ program. These are used to add header files to a program. Preprocessor directives start with the # sign and a keyword "include" is used with start angle bracket and end angle bracket.
Example: #include<conio.h>

Another way of including header files is #include "conio.h" but the better way to add header files is above method.

Header File:
Header file contains the libraries and function about what to do in program... like "iostream.h" it contains the input and output libraries and also general math functions.
A header file has the extension of ".h".

Main Body:

Main body contains the code section of the program. It is the place where the actual working of a program starts. All variable declaration, initialization and other things like comments are mention there.

What is c++ ?

C++ is a High-Level programming language which is used to write programs. It is easy to learn.
C++ is an OOP Object Oriented Programming. It was invented in 1979 at Bell Labs. It is used to develop applications, software and device drivers. For more history, you can visit Wikipedia.

Tuesday 11 October 2016

What is interpreter ?

Interpreter:

Interpreter is a program that also does work of compiling like compiler but the difference is that it converts only one line at one time.

The disadvantage of the interpreter is that it is slow than compiler but provide the facility to check code line by line where an error comes it stops compiling until the line is free from error.