Monday, December 21, 2015

Let's Start Now C++ Stuffs.

  >>> Example 1: A simple Program which prints "Get Logic For C++" On screen.

                            // First Program:

                                                          void main()

                                                                     Cout<<"Get Logic For C++";

                              OutPut : Get Logic For C++

   >>> Let's take a look at each line of code:

    >>> I thingk you all know why I add conio.h header file because i want to use two functions of it clrscr() which will clear the screen and getch() which waits to take the input form the user.

            //First Program
                      >>> It's comment line.

      #include <iostream.h>

               >>> This line is read " Pound include i - o - stream dot h".

               >>> The effect of this line is to essentially "copy and paste: the entire the file iostream.h into your own file at line. So you can thing if this syntax as replacing the line #include <iostream.h> with the contents of the file iostream.h.

    #inlcude is known as a Preprocessor directive. 

>>> Where is the file iostream.h?

   >>> This is located somewhere in your include path. The path indicates the directories on your computer in which to search for a file if the file is not located in the current directory.

>>> Why do I need include iostream.h?

   >>> In this case, iostream,h is a file containing code fir input/output operations. You need to include iosteam.h so that the compiler knows about the word cout which appears a couple of lines below.

     void main() {

   >>> Every c++ program must have what is known as main function.

   >>> when you run the program the program will go through every line of code in the main function and execute it, If your main is empty the your program will do nothing.

   >>> There are essentially four parts to a function definition. They are the return type function name, the parameter list and the function body in that order.

   >>> In our program return type is void which means that this function will not return any value at all.

      >>> You Can Also Write..

                                       int main ()
                                              return 0;

  >>> In this case:

          return type: int
          function name: main
          parameter list: ()
          function body: {.....}

                    For now, the important thing to remember is that the function body is the part enclosed in {....} ("curly braces"). The { indicates the beginning of the function and the } indicates the end of the function.

   >>> cout<<"Get Logic For C++";

          >>> This is the line that prints out the text string, "Get Logic For C++". You can print out any series of text string by separating them with <<.


No comments:

Post a Comment