1 / 17

Introduction

Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240. Introduction. T.Najah Al_Subaie. CS240. Instructor : Najah AL- Subaie Course URL: http://csc240.wordpress.com/ Text Book:

vern
Download Presentation

Introduction

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Kingdom of Saudi Arabia • Prince Norah bint Abdul Rahman University • College of Computer Since and Information System • CS240 Introduction T.NajahAl_Subaie

  2. CS240 Instructor: Najah AL-Subaie Course URL: http://csc240.wordpress.com/ Text Book: • C++ How to Program, DETITEL & DEITEL, eighth Edition • C++ Without Fear A Biggener's Guide That Makes You Feel Smart, Brian Overland

  3. Course Syllabus

  4. Course Objectives • Learn data types, control structures, functions, and arrays. • Learn algorithms and problem-solving. • Learn analysis of problems using structured programming. • Learn program correctness and verification. • Learn the mechanics of running, testing, and debugging

  5. Grading • 2 Midterms : 25% • Project: 5% • Lab work : 10% • Final exam: 40% • Final lab: 20% • Bonus: +5 Marks (Pop quizzes)

  6. Our first Question !! • What are the differences between hardware and software?!! • Computer hardware is any physical device (e.g. the computer monitor), something that you are able to touch and software (e.g. Internet browser) is a collection of instructions and code installed into the computer and cannot be touched. • What is the relation between SW and HW?? • Software (Instruction) controls hardware (computer).

  7. Programming Languages • Machine Language • The only language computer directly understands • Generally consists of 0s and 1s: • It is difficult to understand by humans. • To calculate wages= rates * hours in machine language: • 100100 010001 // Load • 100110 010010 //Multiply • 100010 010011 //Store

  8. Programming Languages • Assembly language • English-like abbreviations to represent computer operations. • Clearer to humans. • Incomprehensible to computers. • Assemblers : convert program to machine language.

  9. Programming Languages • High-level language • Similar to everyday language. • Uses common mathematical notations. • Clearer to humans. • Incomprehensible to computers. • (compilers): convert program to machine language. • The equation: wages= rate * hours written in C++: Wages=rate * hours;

  10. Basics of C++ Environment • C++ programs typically go through six phases to be executed. • Edit: Programmer types a C++ program. • Preprocess: e.g. include other text files to be compiled. • Compile: translate the C++ program into machine language code. • Link: links the code with the code for the missing functions. • Load: load the executable code on memory. • Execute: CPU executes the program one instruction at time.

  11. Structure of a program Output

  12. Structure of a Program Cont. // my first program in C++ • This is a comment line. • All lines beginning with two slash signs (//) are considered comments and do not have any effect on the behavior of the program. • The programmer can use them to include short explanations or observations within the source code itself. • In this case, the line is a brief description of what our program is.

  13. Structure of a Program Cont. #include <iostream> • Lines beginning with a hash sign (#) are directives for the preprocessor. • The directive #include <iostream> tells the preprocessor to include the iostream standard file. • This specific file (iostream) includes the declarations of the basic standard input-output library in C++,

  14. Structure of a Program Cont. using namespace std; • All the elements of the standard C++ library are declared within what is called a namespace, the namespace with the name std. • So in order to access its functionality we declare with this expression that we will be using these entities. This line is very frequent in C++ programs that use the standard library.

  15. Structure of a Program Cont. int main () • This line corresponds to the beginning of the definition of the main function. • The main function is the point by where all C++ programs start their execution. • int in the left, indicates that main “return” an integer. • The word main is followed in the code by a pair of parentheses (). • Right after these parentheses we can find the body of the main function enclosed in braces {}. What is contained within these braces is what the function does when it is executed.

  16. Structure of a Program Cont. cout << "Hello World!"; • This line is a C++ statement. • A statement is a simple or compound expression. • cout is the name of the standard output stream in C++. • The meaning of this statement is to print “ Hello World!” on the screen. • The semicolon (;) is used to mark the end of the statement. • Semicolon must be included at the end of all expression statements in all C++ .

  17. Structure of a Program Cont. return 0; • The return statement causes the main function to finish. • It indicate that the program ended successfully.

More Related