Thursday, August 15, 2013

Basic Input and Output Statement

After familiarizing with the special characters and its function, it is much better to understand the concept on how to input and output such statement.Learn first the definition and purpose of each statement.

The “cout - statement”

Ø       Is  also called standard output statement or console output.
 Is used for displaying the output into the monitor.
Ø  Its  syntax is as follow:

cout << “variable”;

Ø  the symbol “<<” is called insertion operator.

           Example:

1.       cout << “Programming is Fun!”;
2.       cout << “Hello World!”;
3.        cout << “Enter your name\n”;
4.       cout << “Hi” << name << endl;

The “cin - statement”

Ø   is also called standard input statement or console input.
  Is used to accept the value of the variable.
 Waits for the input to be entered from  the keyboard.
Ø  Its syntax is as follow:

cin >> variable;

Ø  The symbol “>>” is called extraction operator.


Example:

1.       cin >> name;
2.       cin >> number of bulbs;
3.       cin >> number of lightbulb << serial number;



Sample Program using Input and Output Statement

#include <iostream.h>
using namespace std;

int main ()
{
         int name;
         cout << “Welcome to Dev C++! ”;
         cin >> name;

         return 0;
}


The output would be like:
Welcome to Dev C++! Keybo


Programming Tip:

End each program with \n and endl


It is  a good idea to output a new-line instruction ( \n and endl ) at the end of every program. If the last item to be output is a string, then include a "\n "at he end of every string; if not output and "endl" as the last action your program
                               

                                              
                                           "Garbage in means garbage out"
                                                    Programmer's  Saying                                                                   
 
       There are several different ways that a  DEV C++ Programming can perform input and output.
     
       Let's describe first what are called"streams". An Input stream is simply the stream of the input that is being fed into the computer for the program to use. The word "stream" suggests that the program processes the input in the same way no matter where the input comes from.

       The intuition for the word "stream" is that the program sees only the stream of input and not the source of the stream, like mountain stream whose water flows past you but whose source  is unknown to you. Similarly, an Output stream is the stream of output generated by the program where in the output is going to a terminal screen.

                
                            SPECIAL CHARACTERS AND SYMBOLS IN DEV C++



                    In Dev C++ programming, it is important to understand also the functions and usage of  "special characters and symbols" that will be useful in doing your program, thus to be able to come up with a good and running program.   Above is the chart showing the special characters ,symbols and its functions.