Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.

Similar presentations


Presentation on theme: "Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing."— Presentation transcript:

1 Introduction of C++ language

2 C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing problem. Like:  FORTRAN: Formula Translation  COBOL: Common Business Oriented Language Other programming languages can be used to solve diverse types of computing programs:  BASIC: Beginners All-purpose Symbolic Instruction Code  C

3 Background C++ is based on C; in fact, C++ is a superset of C.  Developed by Bjarne Stroustrup at AT&T Bell Laboratories Standard C++  Was formally adopted by American National Standards Institute and ISO to provide a common base in 1998 - our course is based on C++ as represented by “The C++ Programming Language”, Third Edition by B. Stroustrup

4 C and C++ C is a procedure oriented language designed to be,  As powerful  As fast  “Close to the machine”  portable C++ is object oriented language. C++ is the “next generation”. C++ is an extension version of C language.  New features for writing programs C and C++ compilers are very advanced pieces of software

5 What is C++ C++ can be “Object Oriented”  Describe objects (things)  What to do with them It is very fast and very powerful C++ is EASIER than C C++ is able to map the real world problem.

6 Applications of C++ C++ allows expression of abstract ideas. C++ has national standards. C++ is reusable and object oriented. C++ is widely used and taught.

7 7 The “Hello, World!” program C notation #include //include header file void main( ) { printf(“Hello, World!”); }

8 8 The “Hello, World!” program C++ notation #include //include header file void main( ) { cout << “Hello, World!”; }

9 Basic structure of C++ program The general structure of C++ program is subdivided into different sections: Documentation section Include files Global Declaration section Main C++ program function Beginning of the program using { End of the program using } Sub-program section having user defined functions

10 Documentation section C++ support two ways to insert comments:  Line Comment- indicates by symbol //  Block comments- start with /* and end with */ - apply to as many lines as you like Used to describe the code in English or provide non-code information E.g. to include the name of the program or the author’s name

11 Include files Pre-compiler statements are divided into two sections. One is link section and other is definition section. In link section we link the compiler in-built function like cin>>, cout<<, clrscr() etc with INCLUDE subdirectory header files like iostream.h, conio.h etc. Like: #include has operators for performing input and output within the program.

12 Include files Ends with a semicolon Follows #include directives in the code Must appear in all programs

13 Global declaration section Data type v1,v2,v3…….vn; Data types are int, float, char etc. and v1,v2….vn are variables. For example, global variables are declared as: int a,b,c; float x,y;

14 Main C++ program function called main Exactly one main function per program A function is a collection of related statements that perform a specific operation int indicates the return type of the function ( ) indicates no special information passed to the function by the operating system. Like: Main() or void main()

15 Beginning of the program {- the beginning of the main program can be done by using curly bracket “{“.  Local variable declaration - int a,b,c;  Executable statements - specify the actions the program will take: cout << “Enter the values of a and b:”; cin >> a>>b;

16 End of the program Ending of the main program:  } – by using this bracket “}” we can end the main program in C++ language.

17 Sub-program section having user defined functions Function 1() { user defined program or body of the function sub program } Function 2() { Another user defined sub program }

18 Compiling and linking Compiler refers to the processing of source code files(.c,.cpp) and creation of an ‘object’ file. The compiler is a program that takes the code that you write and translates it into machine language Machine code is made up of many simple instructions composed of 0 ’s and 1 ’s Linking refers to the creation of a single executable file from multiple object files. Now type the program from first row and the first column. This is called editing.

19 Compiling and linking If you want to save the program, then either press F2 function key from the keyboard or select the save option from the file menu. If you want to compile a C++ program then either select from the Compile menu or press Ctrl+F9.

20 IDE Integrated Development Environment. All in one system for developing programs. Can edit, compile, link and execute our programs all from the comfort of our IDE.


Download ppt "Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing."

Similar presentations


Ads by Google