You are eligible to vote for Havenworld. Click here to vote!

Welcome to Havenworld's Gaming, Computing and Programming Forums!

Unlock extra board access and remove this notice by registering for free below:
Choose username: Email:
Choose password: Antibot:
Type the letters shown in the picture to the left:
Verify password:

Pages: [1]   Go Down
  Print  
Author Topic: Begginers guide  (Read 705 times)
CodeUsa
SEE PLUS PLUS MASTAH
Ex-Staff
Top Banana
***

Reputation: 1
Offline Offline

Posts: 36
Cb level: 3 (Play)
Total level: 30


void if_removed; /* warranty */


« on: October 21, 2009, 04:25:51 am »


Did this has a assignment for class


Code: [Select]
=
Assigns what is on the right to what is on the left. If a was 12, then a is now 25.

a = a + 13;

==
Asks whether what is on the right equals what is on the left. If a is 25, then this is false.

 (a == 56)

()
Groups code to clear up any ambiguities in the order of their evaluation. Also calls a function.

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

{}
Groups larger blocks of code.

for (i = 0; i < 10; i++)
   {
      sum = sum + i;
   }

[]
An array subscript.

x[23] = 6;

;
Terminates a statement.

x = x * x;



Shorthand Operators

Code: [Select]
++
Increment
i++;

is the same as
i = i + 1;
--
Decrement
i--;

is the same as
i = i - 1;
+=  
b += 100;

is the same as
b = b + 100;
-=  
c -= 10;

is the same as
c = c - 10;




switch statements
if/else commands
while loops
do-while loops
for loops
nested for loops
break statement
goto statement
continue statement
return statement

 [SIZE="7"]Switch[/SIZE] statements allow for multiple decisions:

Code: [Select]
switch (year) {
   case 1: {
      Edit1->Text = "You are a Freshman.";
      break;
   }
   case 2: {
      Edit1->Text = "You are a Sophomore.";
      break;
   }
   case 3: {
      Edit1->Text = "You are a Junior.";
      break;
   }
   case 4: {
      Edit1->Text = "You are a Senior.";
      break;
   }
   default: {
      Edit1->Text = "Are you a Grad?";
   }
}

[SIZE="7"]if / else[/SIZE]  commands execute blocks of code only if the value in parentheses is true:
A single block of code may be executed:

Code: [Select]
if (gpa > 3.25) {
   Edit1->Text = "Better than good.";
}

Any or all blocks of code may be executed:

Code: [Select]
if (zipCode == 90290) {
   Edit1->Text = "You live in Topanga.";
}
if (zipCode == 90230) {
   Edit1->Text = "You live in Culver City.";
}
if (sex == 0) {
   Edit2->Text = "You are female.";
}
if (units > 16) {
   Edit3->Text = "You are full time.";
}

Only one of the two blocks of code will be executed:

Code: [Select]
if (hunger > 50) {
   searchForFood();
}
else {
   searchForMate();
}

Only the first true if or else if block, or the else block will be executed:

Code: [Select]
if (hungerForChocolate > 10) {
   goForChocolate();
}
else if (thirstForWater > 50) {
   goForWater();
}
else if (wakefulness < 70) {
   goForCoffee();
}
else if (thirstForWater < 30) {
   goForWater();
}
else {
   goHome();
}

while loops test a condition at the beginning of the code block.
The code is never executed unless the condition is met.

Code: [Select]
while (runWayClear == true) {
   allowAircraftToLand();
}

In this case you will never allow an aircraft to land if the runway is not clear.

do-while loops test a condition at the end of the code block. The code is always executed once.

Code: [Select]
do {
   dance();
}
while (musicStopped == false);


In this case you will always have one dance, even if the music has stopped.

for loops take three parameters enabling you to initialize, terminate and increment the loop counter:
Assuming you wished to do something with each agent from id 23 to 79,
setting first id to 23 and last id to 79 would do the job.
If you wanted every odd numbered agent from 23 to 79 the last parameter would be id = id + 2:

Code: [Select]
for (int id = first; id <= last; id = id + 1) {
   // these agents increase in age
   agent[id].age ++;
}

The  break statement causes an immediate exit from a switch or any kind of loop:

Code: [Select]
for (student = 0; student < 500; student++) {
   if (score[student] == 99) break;
}
// we have found the first student with
// a "99" score

The  goto statement may be used to break out of a double or more deeply nested loop:

Code: [Select]
for (row = 0; row < 500; row ++) {
   for (column = 0; column < 500; column ++) {
      // look for row and column containing 77
      if (77 == cell[row][column]) {
         goto exit;
      }   
   }
}
exit:
// we have now found the row and column
// of the first cell containing "77"

The  continue statement returns you to the loop's beginning,
skipping statements that follow it and incrementing the loop counter:

Code: [Select]
for (student = 0; student < 500; student++) {
   if (score[student] < 50) continue;
   score[student] = score[student] * 1.2;
   bonus[student] = true;
   bonusesAwarded++;
   notify(student);
   notify(professor);
}
// students with scores of "50" or
// higher receive extras

The  return statement causes an immediate exit from a function:

Code: [Select]
int addTwoNumbers (int a, int b) {
   sum = a + b;
   return sum;
}

Operators in
order of Precedence

Code: [Select]
Operators in
order of Precedence
()
Function call
[]
Array subscript
->
Indirect component selector
.
Direct component selector
!
Logical negation
+
Plus
-
Minus
()
Expression parentheses
*
Multiply
/
Divide
%
Remainder (modulus divide)
<
Less than
<=
Less than or equal to
>
Greater than
>=
Greater than or equal to
==
Equal to
!=
Not equal to
&&
Logical and
||


Logical or
=
Assignment

Enjoy.
_Anthony
One leaf
*

Reputation: 0
Offline Offline

Posts: 20
Cb level: 3 (Play)
Total level: 30


« Reply #1 on: November 15, 2009, 07:47:33 am »

It's been over a year yet you still fail miserably at leeching.

http://www.duke.edu/web/isis/gessler/borland/cpp.htm
Danny
Forumizer
Havenworld Junkie
*****

Reputation: 16
Offline Offline

Posts: 2966
Cb level: 13 (Play)
Total level: 305


Zazeca


WWW
« Reply #2 on: November 15, 2009, 09:22:15 pm »

Lol, I didn't think he wrote this... it's not like CodeUsa to put in much effort into his posts.
Mod Penguinn
Gold Member
****

Reputation: 7
Offline Offline

Posts: 180
Cb level: 3 (Play)
Total level: 30


AllScript Guru


WWW
« Reply #3 on: February 04, 2010, 10:25:06 pm »

all i have to say is... lmao. leech tmx.
Hater
Senior Member
*****

Reputation: 0
Offline Offline

Posts: 83
Cb level: 3 (Play)
Total level: 30


« Reply #4 on: February 05, 2010, 08:41:21 pm »

It's been over a year yet you still fail miserably at leeching.

http://www.duke.edu/web/isis/gessler/borland/cpp.htm

Lol'd. Gf.

2/10 for effort :)
CrnJacKer
Global Moderator
Havenworld Guru
*

Reputation: 20
Offline Offline

Posts: 856
Cb level: 3 (Play)
Total level: 30


Im a Proud Egyptian.


« Reply #5 on: February 06, 2010, 08:25:25 am »

Locked, seeming as this is ripped.
Pages: [1]   Go Up
  Print  
 
 

Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC | Havenworld © 2006 - 2009 Havenworld Plc
Page created in 0.245 seconds.