Lang. C Dictionary (Minior)

Just note - I am a begginer and want to share my learning prossess with you. I can teach you, but my definitions my be a bit off (Hopefully not :D). Most of what I know comes from a book called, Sams Teach yoursef C Programming in One Hour a Day.

Note: Don't forget the semi-colin (;)

Varables:

int - An interger, use as: int <name> = <value/assignment>;

float - For decimals, example: float <name> = <value/ex: 3.34>; By default it will show 6 numbers after decimal, 3.34 = 3.340000. You can chnage this in the coding, ex: printf("The Value %0.2f",floatvar); In this example the varable floatvar is 3.34, so instead of putting %f, you can put, %0.<Numb>f so if I put 2 for the number, it would show as: 3.34 and not 3.340000.

long - This is pretty musch the same as an integer, expect it is good for storing more data, ex: long numbs = 32 * 3 - 67/43 +32499390;

Commands:

printf - This is the most basic command in C, it is used to show words, ex: printf("Hello World");

scanf - This asks for the user to type something in, ex: scanf("%d",numbInput); with %d it will only allow numbers. (Not decimals)

rand - This is used to randomize things, I prefer it in variables: int test = rand() % 6 +1; This will randomize a number from 1-7.

Functions:

int main - This is the very basic function for every program, it is required, ex: int main() {}

if - This function is used to see if something meets the requirements, if so, it runs, ex: if (apples == 10) { printf("Ya"); }

While - This runs the command while something is true, ex: while (apples == 10) { printf("YA!"); }

Define:

#define - This is a variable that cannot be changed, they are ushally all in CAPS and at the very top of the program: #define apples 10

(No semi-colin for these!)

Other:

CREDIT:

Sams Teach yoursef C Programming in One Hour a Day. (Book)