71
CS 240 Computer Programming 1 Teacher Assistant Hadeel Al-Ateeq ١ PDF created with pdfFactory trial version www.pdffactory.com

CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

CS 240Computer

Programming 1Teacher AssistantHadeel Al-Ateeq

١

PDF created with pdfFactory trial version www.pdffactory.com

Page 2: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Announcement

DON’T forgot to SIGN yourschedule OR you will not

be allowed to attend next lecture.

Hadeel Al-Ateeq

٢

PDF created with pdfFactory trial version www.pdffactory.com

Page 3: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Communication

E-mail:õ[email protected]

Hadeel Al-Ateeq

٣

Office hours:õ Saturday(10-12).õ Sunday(9-10).õMonday (8-9).

PDF created with pdfFactory trial version www.pdffactory.com

Page 4: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Textbook

“HOW TO PROGRAM BY C++ DEITEL AND DEITEL”,

Seventh edition.

٤

PDF created with pdfFactory trial version www.pdffactory.com

Page 5: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Grades

Hadeel Al-Ateeq

٥

Evaluation Type GradeHomework 2%Evaluation 5%

Project 5%Final Lab 20%

Total 32%

PDF created with pdfFactory trial version www.pdffactory.com

Page 6: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Installing C++ VB.NET Express Edition

Hadeel Al-Ateeq٦

PDF created with pdfFactory trial version www.pdffactory.com

Page 7: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Software Required

õMicrosoft Visual C++ 2008 Express Edition

http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express

õ After opening this page you will find this link.

7

PDF created with pdfFactory trial version www.pdffactory.com

Page 8: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Download8

PDF created with pdfFactory trial version www.pdffactory.com

Page 9: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Download9

PDF created with pdfFactory trial version www.pdffactory.com

Page 10: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Install

õAfter downloading, you will get this:

õDouble click.

10

PDF created with pdfFactory trial version www.pdffactory.com

Page 11: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Install11

PDF created with pdfFactory trial version www.pdffactory.com

Page 12: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

12

Install

PDF created with pdfFactory trial version www.pdffactory.com

Page 13: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

13

Install

PDF created with pdfFactory trial version www.pdffactory.com

Page 14: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

14

Install

PDF created with pdfFactory trial version www.pdffactory.com

Page 15: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

15

Install

PDF created with pdfFactory trial version www.pdffactory.com

Page 16: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

16

After clicking Exitopen Visual C++Then register theproduct.

Install

PDF created with pdfFactory trial version www.pdffactory.com

Page 17: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Opening Visual C++ 2008 Express Edition

17

PDF created with pdfFactory trial version www.pdffactory.com

Page 18: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Register18

PDF created with pdfFactory trial version www.pdffactory.com

Page 19: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

19

Register

PDF created with pdfFactory trial version www.pdffactory.com

Page 20: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

õ Sign in with your MSN Hotmail account OR MSN Messenger account

õ Then, Click Sign in.

20

Register

PDF created with pdfFactory trial version www.pdffactory.com

Page 21: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

õ Fill out the online registration form. Then click Continue

21

Register

PDF created with pdfFactory trial version www.pdffactory.com

Page 22: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

register

22

PDF created with pdfFactory trial version www.pdffactory.com

Page 23: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

õ You will receive Verification E-Mail from Microsoft.

õ Open your email to verify ownership of your email by clicking the link in the email.

õ A web page will be opened.

õ click Continue.

23

Register

PDF created with pdfFactory trial version www.pdffactory.com

Page 24: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

register

Copy the Key

24

PDF created with pdfFactory trial version www.pdffactory.com

Page 25: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

25

Register

PDF created with pdfFactory trial version www.pdffactory.com

Page 26: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

26

Register

PDF created with pdfFactory trial version www.pdffactory.com

Page 27: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

DONE!

Now Microsoft Visual C++ 2008 is ready to use.

27

PDF created with pdfFactory trial version www.pdffactory.com

Page 28: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Creating a Program

Hadeel Al-Ateeq٢٨

PDF created with pdfFactory trial version www.pdffactory.com

Page 29: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Create a Project٢٩

PDF created with pdfFactory trial version www.pdffactory.com

Page 30: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Create a ProjectThis is the default

location of the project

٣٠

PDF created with pdfFactory trial version www.pdffactory.com

Page 31: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Create a Project

C:\Users\Eman\Documents\Visual Studio 2008\Projects

This Folder differs depending on your user name in your

computer.

٣١

PDF created with pdfFactory trial version www.pdffactory.com

Page 32: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Create a ProjectNow, the project is created and shown in the Solution Explorer

٣٢

PDF created with pdfFactory trial version www.pdffactory.com

Page 33: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Solution ExplorerSolution Explorer

Solution Name = Project Name

Project Name

٣٣

PDF created with pdfFactory trial version www.pdffactory.com

Page 34: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Solution ExplorerIf you can not see Solution Explorer, you can show it as the following: view è Solution Explorer

٣٤

PDF created with pdfFactory trial version www.pdffactory.com

Page 35: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Create a Project

If you want to save your project in a folder on the desktop. How to do it?

٣٥

Create a folder on the desktop, give it a name:CS240-Yourname-yourIDfor example: CS240-NoraAlAhmad-430123123

PDF created with pdfFactory trial version www.pdffactory.com

Page 36: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Create a Project٣٦

PDF created with pdfFactory trial version www.pdffactory.com

Page 37: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

٣٧

This is the folder name that you want to create the project in it

PDF created with pdfFactory trial version www.pdffactory.com

Page 38: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Create a ProjectHere, The Project

location is a Folder on the

desktop.

٣٨

PDF created with pdfFactory trial version www.pdffactory.com

Page 39: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Adding Source File(.cpp file)

٣٩

õYou have to write your program in a file called Source File and its extension is .cpp

õSo, you have to add a Source File to your project to write your program in it.

PDF created with pdfFactory trial version www.pdffactory.com

Page 40: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Adding Source File(.cpp file)

٤٠

PDF created with pdfFactory trial version www.pdffactory.com

Page 41: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Adding Source File(.cpp file)

٤١

PDF created with pdfFactory trial version www.pdffactory.com

Page 42: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Adding Source File(.cpp file)

٤٢

PDF created with pdfFactory trial version www.pdffactory.com

Page 43: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Writing a Program

Hadeel Al-Ateeq٤٣

PDF created with pdfFactory trial version www.pdffactory.com

Page 44: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

٤٤

Main parts of any C++ program

PDF created with pdfFactory trial version www.pdffactory.com

Page 45: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Main parts of any C++ program

#include<iostream>using namespace std;int main(){

return 0;}; also is important at end of each statement

٤٥

PDF created with pdfFactory trial version www.pdffactory.com

Page 46: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Main parts of any C++ program

#include<iostream>using namespace std;void main(){

}; also is important at end of each statement

٤٦

PDF created with pdfFactory trial version www.pdffactory.com

Page 47: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

õWhat happened when one of the main parts is missing?õLet’s try together!

٤٧

Main parts of any C++ program

PDF created with pdfFactory trial version www.pdffactory.com

Page 48: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

cout Command

Used to print a specified message on the output screen.

٤٨

Cout << …………………………… ;

Syntax

Description

PDF created with pdfFactory trial version www.pdffactory.com

Page 49: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

cout Commandõ Let’s write this program together.

٤٩

PDF created with pdfFactory trial version www.pdffactory.com

Page 50: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Comments

Hadeel Al-Ateeq

٥٠

Used to describe the code segments briefly.

// your comment

Syntax

Description

PDF created with pdfFactory trial version www.pdffactory.com

Page 51: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Hadeel Al-Ateeq

٥١

Comments

PDF created with pdfFactory trial version www.pdffactory.com

Page 52: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

How to Debug a program٥٢

PDF created with pdfFactory trial version www.pdffactory.com

Page 53: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

How to Debug a program٥٣

PDF created with pdfFactory trial version www.pdffactory.com

Page 54: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Program output٥٤

PDF created with pdfFactory trial version www.pdffactory.com

Page 55: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Errors٥٥

This means your program has no WARNINGS

This means your program has no ERRORS

PDF created with pdfFactory trial version www.pdffactory.com

Page 56: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Saving your

Program

Hadeel Al-Ateeq٥٦

PDF created with pdfFactory trial version www.pdffactory.com

Page 57: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Save your program٥٧

PDF created with pdfFactory trial version www.pdffactory.com

Page 58: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Exit VC++

٥٨

OR1. 2.

PDF created with pdfFactory trial version www.pdffactory.com

Page 59: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Opening a Project

Hadeel Al-Ateeq٥٩

PDF created with pdfFactory trial version www.pdffactory.com

Page 60: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Open a project٦٠

õTo open a previously created project, there are two ways:

õFile è Recent Projects used if the project is recently created.

õFile è Open è Project/Solution

PDF created with pdfFactory trial version www.pdffactory.com

Page 61: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Open a project٦١

õ File è Recent ProjectsThen, choose the project.

PDF created with pdfFactory trial version www.pdffactory.com

Page 62: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Open a project٦٢

õ File è Open èProject/SolutionThen, Browse for the project file.

PDF created with pdfFactory trial version www.pdffactory.com

Page 63: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Open a project٦٣

PDF created with pdfFactory trial version www.pdffactory.com

Page 64: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Open a project٦٤

PDF created with pdfFactory trial version www.pdffactory.com

Page 65: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Open a project٦٥

PDF created with pdfFactory trial version www.pdffactory.com

Page 66: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Printing Code

Hadeel Al-Ateeq٦٦

PDF created with pdfFactory trial version www.pdffactory.com

Page 67: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Make sure that the is located cursor

HERE

PDF created with pdfFactory trial version www.pdffactory.com

Page 68: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

PDF created with pdfFactory trial version www.pdffactory.com

Page 69: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Sending the Source File (.cpp)

Hadeel Al-Ateeq٦٩

PDF created with pdfFactory trial version www.pdffactory.com

Page 70: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

This the file that contains your code. This is what you should send to me.

Project Name

PDF created with pdfFactory trial version www.pdffactory.com

Page 71: CS 240 Lecture 1 - WordPress.com · CS 240 Computer Programming 1 Teacher Assistant HadeelAl-Ateeq ١ PDF created with pdfFactory trial version

Locate the .cpp file The Project folder

= Project Name

This the file that contains your code. This is what you should send to me.

PDF created with pdfFactory trial version www.pdffactory.com