Introduction cont
Download
1 / 11

Introduction\_Cont . - PowerPoint PPT Presentation


  • 101 Views
  • Uploaded on

Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240. Introduction_Cont . T.Najah Al_Subaie. Objectives:. In this section you will learn: Learn C++ standard library, standard streams and names space.

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

PowerPoint Slideshow about 'Introduction\_Cont .' - ailani


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
Introduction cont

Kingdom of Saudi Arabia

  • Prince Norah bint Abdul Rahman University

  • College of Computer Since and Information System

  • CS240

Introduction_Cont.

T.NajahAl_Subaie


Objectives
Objectives:

  • In this section you will learn:

  • Learn C++ standard library, standard streams and names space.

  • Learn how to get input from the keyboard.

  • Learn how to write an output on the screen.

  • Learn how to use the escape sequences.

  • Learn C++ syntax rules.

  • Learn how to write a psudocodeand convert it to a C++ program.


C standard library
C++ Standard Library

  • Rich collections of existing code that can be reused in your applications:

    • Common math calculations e.g. sqrt,sin,cos

    • Input/output

    • Date/Time

  • Provided as part of the C++ development environment

  • All C++ library entities are defined in one or more standard headers.

  • You can use the capabilities by referring to the corresponding header file.


Iostream library
Iostream Library

  • Part of the C++ Standard Library

  • Provides a uniform way of handling input from (and output) predefined sources.

  • Based on the concept of a “stream”.

  • Stream:

    • Streams are generally connected to a physical source or destination of characters:

      • A disk file, the keyboard, or the screen.


Streams 1
Streams(1)

  • Two types:

    • Input streams: used to hold input from a data producer , such as keyboard, a file.

    • Output streams: used to hold output for a particular data consumer such as a monitor, a file or a printer.


Streams 2
Streams(2)

  • Standard input stream (cin )

  • Standard output stream (cout)

    Note:

  • Keyboard-- program ( cin>>)

  • Program --- screen (cout<<)


Using cout
Using cout

  • Stream insertion operator <<

    • Value to right (right operand) inserted into left operand

      • Example:

        • Cout<<“Hello”;

        • Insert the string” Hello” into the standard output stream(cout).

        • Displays to the screen.

    • Escape characters:

      • A character preceded by”\”

      • Indicates “ special “ character output

      • Example:

        • “\n”

        • Courser moves to the beginning of the next line on the screen.




Syntax rules
Syntax Rules

  • You must includes <iostream> for cout to work properly.

  • You must use the namespace std for the cout to work properly.

  • C++ is case sensitive. Make sure you don’t’ capitalize any of the letters in C++ keywords.

  • Every statement ends with a ; except for include statements.

  • String literals must be enclosed in “”.

  • Main function must return a value to the OS.

  • Every Opening brace { must have an enclosing brace}.


Examples 2 adding integers
Examples(2): Adding integers

  • Write a program that displays the sum of two integers entered at the keyboard:

    • Define the problem precisely.

    • Write the psudocode that will solve the problem

    • Use an Editor to create source code in C++.

    • Use the compiler to

      • Check that source code obeys the language rules.

    • If no errors: Execute your program.