introduction to c n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to C++ PowerPoint Presentation
Download Presentation
Introduction to C++

Loading in 2 Seconds...

play fullscreen
1 / 13

Introduction to C++ - PowerPoint PPT Presentation


  • 89 Views
  • Uploaded on

Introduction to C++. Objectives of this session. What is C++ A Simple Program Comments in C++ Output Operator Input Operator Cascading of I/O Operator Structure of a C++ Program. C++. C++ is an object-oriented programming language.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

Introduction to C++


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. Introduction to C++

    2. Objectives of this session • What is C++ • A Simple Program • Comments in C++ • Output Operator • Input Operator • Cascading of I/O Operator • Structure of a C++ Program

    3. C++ • C++ is an object-oriented programming language. • Developed by Bjarne Stroustrup at AT&T Bell Laboratories, USA in the early 1980’s. • Simule 67 + C language  C++ • 1997 November ANSI/ISO standards committee standardised C++. • For developing editors, compilers, databases, communication systems, etc.

    4. A Simple Program • C++ works by giving (separate) instructions to the computer. • These instructions can be written as functions. • The primary function used in C++ is called main. This means that every C++ program should have the main() function. Because a function is an assignment, in order to perform its job, a function has a body. The body of a function starts with an opening curly bracket "{" and closes with a closing curly bracket "}".

    5. // my first program in C++ #include <iostream.h> int main ( ) { cout << "Hello World!"; return 0; } Hello World! A Simple Program continue…

    6. Comments in C++ • The most basic documentation you have to perform is to put comments as much as you can. Comments help you and other people who read your code to figure out what you were doing. • Comments are not read by the compiler while executing your program. • C++ supports two ways to insert comments: • // line comment • /* block comment */

    7. Comments in C++ continue… // The hello.cpp program // Include the iostream library #include <iostream.h> int main( ) { /* Here is a simple sentence that I want to display when the program starts. It doesn't do much. I am planning to do more stuff in the future. */ cout << "Hi, this is my program!"; return 0; } // The end of my program

    8. Output Operator cout << "Hi, this is my program!"; cout is a predefined object that represents the standard output stream in C++, here the standard output stream is screen. screen << cout C++ variable Object Insertion Operator

    9. screen << cout C++ variable Output Operator continue… • The operator << is called insertion or put to operator. • It inserts ( or sends ) the contents of the variable on its right to the object on its left. cout << "Hi, this is my program!"; cout << number ; Object Insertion Operator

    10. Input Operator cin >> number1; cin is a predefined object that corresponds to the standard input stream in C++, here the standard input stream is keyboard. Object Extraction Operator C++ variable >> cin 50.55 Keyboard

    11. Input Operator continue… Object Extraction Operator C++ variable • The operator >> is known as extraction or get from operator. • It extracts ( or takes ) the value from the keyboard and assigns it to the variable on its right. >> cin 50.55 Keyboard

    12. Cascading of I/O Operators • Multiple use of << or >> in one statement is called cascading. eg:- cout << “Sum = ” << sum << “\n”; cin >> number1 >> number2;

    13. Include files Class declaration Member functions declaration Main function program Structure of a C++ Program Better to organize a program file into three separate files. • Class declarations in a header file. • Definition of member function in a separate file. • The main program that uses the class is placed in a third file which includes the previous two files.