iasteele

 

Angela

Page history last edited by Angela 2 yrs ago

start off with:

 

#include <stdio.h> 

#include <stdlib.h>

 

void main()

{

 

while(1);

}

 

 

Variable Types:

 

there are integers(whole numbers)         int

characters(alphabet)                               char

floating point number(real number)         float

string (an array of characters)                 string

 

 

char name[64] = string %s (array of characters);

int name[6] = % array of ints

 

name[5] %c = 'e'

name      %s = "Mr.Steele"

 

*the [*#*] starts with 0 and counts up

 

 

Printf:

to print something on the screen:

printf("ABC ");

** have ";" after all statments except when {} are directly after.

 

if something is typed into the computer, then put a ":" after the text.

 

if something already saved into the file needs to be printed, put in ("ABC %i", variable) and the %i will be replaced by what is saved in variable.

 

Scanf:

saves *number* typed into the computer until the black window is exited.

scanf("%i", &variable)

this means what is typed in from the printf will be saved in variable.

 

 

If and Else:

if:

used when certain parts must be meet for certain things to happen.

 

if(x < %i)

 

}

this means if x is less than %i, then what is written in the {} will be done otherwise...

 

use else.

 

else:

used after "if"

does exactly the opposite of the if.

 

 

Loops

while:

happens while something else happens and stops when certain conditions are met.

 

for:

(int i = ##, i > ##, 1 = i + 1).

example

for(int i=0;i<11;i++)

 

Arrays

many characters after one another (aka a string)

or

many ints after another (an array)

 

Functions

can plug in numbers and get another number

usually place in the beginning of the script

you can do math with them.

 

 

Comments (0)

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