inleiding tot programmeren - practicum 2

Post on 29-Nov-2014

571 Views

Category:

Technology

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Inleiding tot ProgrammerenPracticum 2Ruben Van den BosscheRuben.VandenBossche@ua.ac.be

Practicum 2

• Projecten importeren en exporteren• Voorbeeldcode: gobelijn• Types• if-statement• for-lus• while-lus

2

Project exporteren

• Klik File > Export• Kies General > Archive file• Selecteer de projecten die je wil exporteren

• Geef het archief een naam en locatie- Klik Browse...- Kies naam en locatie

• Klik Finish

3

Project importeren

• Klik File > Import• Kies General > Existing projects into workspace• Kies Select archive file• Klik Browse naast Select archive file• Selecteer het Eclipse-archief• Klik Finish

4

Opslagmogelijkheden

• Mail• Fileserver UA

- Places > Connect to Server

• Dropbox- Gratis en veelgebruikt- Registreren via http://db.tt/Uy2utDw

5

Practicum 2

• Projecten importeren en exporteren• Voorbeeldcode: gobelijn• Types• if-statement• for-lus• while-lus

6

Voorbeeldcode: Gobelijn

• Op computers in computerklas• In Virtuele Machine

• Build via “Make targets”- bootstrap- build_all- remove_build

7

Practicum 2

• Projecten importeren en exporteren• Voorbeeldcode: gobelijn• Types• if-statement• for-lus• while-lus

8

Types• int• double• char• bool

• string- speciaal geval- schrijf #include <string>bovenaan je programma!

9

Practicum 2

• Projecten importeren en exporteren• Voorbeeldcode: gobelijn• Types• if-statement• for-lus• while-lus

10

if-statement• Relatie-operatoren

==, !=, <, >, <=, >=• && betekent and, || betekent or, ! betekent not

11

// example of an if-statementif ((x <= 5) && (y != 7)){

z = 12;}else if (x > 5){

z = 13;}else{

z = 14;}

Practicum 2

• Projecten importeren en exporteren• Voorbeeldcode: gobelijn• Types• if-statement• for-lus• while-lus

12

for-lus• for-header bevat 3 delen:

- int i = 0: Initiële expressie, wordt uitgevoerd bij aanvang van de lus

- i < 10: Als conditional == true wordt body uitgevoerd. Conditional wordt gecontroleerd voor elke iteratie.

- i++: Finale expressie, wordt uitgevoerd aan het einde van elke iteratie.

13

// example of a for-loop from 0 to 9for(int i = 0; i < 10; i++){cout << i;

}

Practicum 2

• Projecten importeren en exporteren• Voorbeeldcode: gobelijn• Types• if-statement• for-lus• while-lus

14

while-lus

15

// example of a while-loopwhile (x < 5){y = z + x;x += 1;

}

• while-lus wordt uitgevoerd zolang conditie waar is.

top related