introduction c++ i. elaf alhazmilab1 programming course

Post on 03-Jan-2016

219 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

INTRODUCTION C++

I. Elaf Alhazmi LAB1

Programming course

2

Microsoft Visual Studio 2010 (Open New File)

We will training on Microsoft Visual Studio 2010 for C++ program.

Open Visual Studio 2010

Ins. Elaf Alhazmi Computer Programming (lab)

Ins. Elaf Alhazmi Computer Programming (lab)

3

Microsoft Visual Studio 2010 (Open New File)

Open New project Then win32 then Win32 Conslot project Or Empty Project if available

اسم نكتبالمشروع

Ins. Elaf Alhazmi Computer Programming (lab)

4

Microsoft Visual Studio 2010 (Open New File)

نختار“Applica

tion Setting

In case you selectwin32 then Win32 Conslot project then Application Setting

Ins. Elaf Alhazmi Computer Programming (lab)

5

Microsoft Visual Studio 2010 (Open New File)

نختار -1“Empty

project”

نختار -2“Finish”

Ins. Elaf Alhazmi Computer Programming (lab)

6

Microsoft Visual Studio 2010 (Open New File)

مجلد على الفأرة في اليمين بزر Source fileضغطAddثم New itemثم

Ins. Elaf Alhazmi Computer Programming (lab)

7

Microsoft Visual Studio 2010 (Open New File)

نختار -1“C++ File

(.cpp) “

نكتب -2إسم الملف

3-

نختار”Add

Ins. Elaf Alhazmi Computer Programming (lab)

8

Microsoft Visual Studio 2010 (Open New File)

الكود نكتب

معرفة االخطاء

نختارStart

Debugging

Ins. Elaf Alhazmi Computer Programming (lab)

9

Program 1

// my first program in C++

#include <iostream>

using namespace std;

int main()

{

cout<< "Hello World!“ ;

system("pause");

return 0;

}

Ins. Elaf Alhazmi Computer Programming (lab)

10

Decleration

DataType Variable_Name = value/expression ;

Initialization مبدئية قيمة

int x;char grade;float PI=3.14;char yes= ‘y’;

Ins. Elaf Alhazmi Computer Programming (lab)

11

Declarations (Variables)

Variable is symbol that represents storage location in the computer’s memory. The information that is stored in that location is called Value

Assignment StatementVariable = Expression ;

int x; int is called data type x is varible

Every variable in C++ program must be declared before it is used.

Ins. Elaf Alhazmi Computer Programming (lab)

12

Variables name

المتغير تسمية شروط األبجدية الحروف غير حرف بأي المتغير يبدأ أن يمكن ال

( A-Z a-z ,)_( )وصاعدا الثاني من األحرف لكن السفلي التسطير حرف أوالسفلي التسطير حرف أو أحرف أو أعدادا تكون أن يمكن

حرف غير تنقيط عالمات أو فراغات على المتغير اسم يحتوي أن يمكن الالتسطير)_(

محجوزة كلمة يكون أن يمكن Reserved wordال االسم بنفس متغيران هناك يكون أن يمكن ال البرمجة لتسهيل معنى ذا المتغير اسم يكون أن األفضل

Ins. Elaf Alhazmi Computer Programming (lab)

13

Reserved words

The syntax rules (or grammar) of C++ define certain symbols to have a unique meaning within a C++ program, must not be used for any other purposes

unsigned

struct short int float double

const auto

void switch signed

long for else continue

break

volatile typedef

sizeof register

goto enum

default

case

while union static return

if extern do char

Ins. Elaf Alhazmi Computer Programming (lab)

14

Data types

String String note: you need #include<string>

Characters Char

Integer Numbers short int long unsigned short unsigned int unsigned long

Real/ Float Numbers float double long double

Ins. Elaf Alhazmi Computer Programming (lab)

15

Arithmetic operation

Symbol Action

= Assignment

+ Addition

- Subtraction

* Multiplication

/ Division

% Modulus ( القسمة ( باقي

Ins. Elaf Alhazmi Computer Programming (lab)

16

Operators and expressions

- (-3* (5 +2 *6)) + (3* 4+4)/2

12

17

- 51

51

12

16

8

59

Ins. Elaf Alhazmi Computer Programming (lab)

17

Operators and Expressions

Priority األقل إلى األعلى من األفضلية the execution of an expression is from

left to right ( ) Negative sign *, / -, +

Ins. Elaf Alhazmi Computer Programming (lab)

18

Declarations & initialization

Just declaration

Declaration and initialization

top related