iasteele

 

Carolyn

Page history last edited by Carolyn 2 yrs ago

 

C++ PROGRAMMING

 

 

 

To begin with:

at top:

#include <stdio.h>

#include <stdlib.h>

 

void main()

{

 

while(1);

}

 

 

Variable Types:

- there are integers (int)                   [numbers like 5, 8]

- characters (char)                             [letters of the alphabet]

- floating point number (float)           [a number with a decimal point/a real number]

- string (string)                                  [an array of characters]

 

 

Printf

 to print something on the screen

always

printf(" TYPE TEXT ")

 

if user of program types, then

printf("TYPE TEXT: ")

 

if number put in, for example an int

printf(" TYPE TEXT %i",variable_name)

 

Scanf

saves number for the given time onto computer

always

scanf("%i", &WHATEVER CALLED)

 

 

If and Else

if:

in certain conditions you can make specific things happen

ex:  if(x < 45)

 

else:

used as opposite condition of "if"

for example:

if(x == 6)

....

else

...

 

 

Loops

while:

happens while something else happens,

it happens again once it is over

 

for loop:

for(int = somthing, int > somehitng, int = int + something)

 

 

Arrays

many characters after one another (aka a string)

many ints after another (an array)

 

Functions

can plug in numbers and get another number

do math with them

 

 

 

 

Comments (0)

You don't have permission to comment on this page.