Monday, June 11, 2012

C++ For Beginner - Non Printing Characters

Non printing characters are also called escape characters. These characters are not printed but are used to format text display

Name of Character :              Meaning :
\n                           New line
\t                           Tab
\b                           Backspace
\0                           Null
\'                           Single quote
\"                           Double quote
\\                           Backslash


C++ For Beginner - Dissection of the Program

1. #include<iostream.h>

The #include directive is a special type of instruction called a preprocessor directive. This is an instruction to the compiler to take the entire file iostream.h andplace it in the program.

The preprocessor is a program that modifies your source file prior to compilation. Common preprocessor directives are #include which is used to include additional code into your source file, #define, which is used to define a constant and #if/#endif, which can be used to conditional determine which parts of your code will compiled.

2. // Prints "Welcome to Turbo C++" on screen

The next line in our program  is a comment. Comments are explanations or annotations that are include in a program for documentation and clarification purposes.

The compiler does not generate machine code for comments. Any line of  text placed after the symbols // or between slash asterisk-asterisk slash /* */ is ignored by the compiler.


There are two wayws to specify a comment in Turbo C++:
  1. In standar C++, we can use /* and */ to surround comments.
  2. Certain C++ compilers permit // to begin comment lines.
Here is an example of placing comments in Turbo C++ programming



























3. int main ( )

This is the function prototype statement for the main function. This is required in every C++ program. Usually, when we start a program, DOS load it and transfers control to it. In orfer to do that, DOS has to know where to enter a program and start executing. Thats what the term int main ( ) if for, DOS looks for the part of the program labeled int main ( ) and start there. In other words, int main ( ) is the label that tags the beginning of the program.

4. { }

This encloses the body of the program.
Usually the curly braces enclose more program line, such as this the ;

#include<iostream.h>
/* The required header file for cout<<( ) is iostream.h
    This is Prints
    The word Welcome Turbo C++ on the screen */
 int main ()       //The main function
{
     cout<<"Welcome Turbo C++" ;
     return 0 ;
}


Statements like this end with a semicolon ( ; ), referred to as statement terminator. Each action in c++ is a statement, and a semicolon must end each one.

5. cout<<

cout (pronounced as "see-out") is used to write output to the standard output, usually the screen. cout means console output.

cout<< "Wecome Turbo C++"; is a sample C++ statement. The output operator << directs the values to the cout output stream. The output stream cout is used with insertion operators << in the syntax.

Because cout<< is the normal way of printing on the screen in C++, it's pretty powerful. We are not limited to just printing words; we also have control over the way we print those words on the screen. For example, we can place the character \n in the character string like this \n

#include<iostream.h>
 int main ()      
{
     cout<<"Welcome Turbo C++ \n ";
     return 0;
}

6. return 0;

This causes the main to return a zero value indicating to the operating system that the program terminated normally.

Saturday, June 9, 2012

C++ For Beginner - Creating Your First C++ Program

1. On your Task Bar click START, then choose Program, Turbo C++ 4.5, click Turbo C++


























 2. On your work-area type the following commands:
#include<iostream.h>
 int main ()
{
    cout<<"Welcome Turbo C++";
    return 0;
}
























 3. Preparing to save your program.
     a. To save your program, on your Menu Bar Click File | Save.
     b. Type firstprogram.cpp as your filename.
     c. Then Click Save.






Friday, June 8, 2012

C++ For Beginner - Parts of the Screen

The Parts of the Screen

Turbo C++ Download Here



























OVERVIEW OF THE MENU BAR




FILE
File related commands that operate on your program file, such as loading a program from disk, saving a program you entered to disk, and printing the program.

EDIT
Includes options that aid in adding, changing, searching for, and deleting text from the current program.

VIEW
Options for moving around the editor and controlling the display

PROJECT
Includes the building command, which runs the compiler and linker and the executable command, which enables you to test your program without leaving the workbench.

BROWSE
Used for examining C++ classes.

DEBUG
This pull-down menu includes the command that enable you to examine the codes as if runs to help you get errors out of your program.

TOOL
Special features that can be added to the workbench

OPTIONS
Setting up the workbench to better suit the way a program works.

WINDOWS
Standard windows menu for selecting and arranging windowss.

HELP