Must-Knowint | -2,147,483,648 to +1,147,483,647 | float | 4bytes,contain 1 digit/decimal, +-10^38, 7digitsprecision,f, illegalfloats: 6.2.2f,6.-3f,6.2 | double | 8bytes,+-10^308,14digitprecise | variable | upper/lowercase differ, reflects data stored, given to memory location | destructive read | Reference | destructive write | Write Over | types of c statements | declarations/arithmetic instructions/control instructions | Order of Operations (L->R) | !, * / %, + -, < > <= =>, == !=, &&, ||, = | Functions | AND (&&), OR (||), NOT (!) | QuadFormula | (-b+sqrt((b*b)-4ac))/(2a) | While Loop | executed 0 or more times. Does test, then body | Do-While Loop | executed 1+ times. Does body, then test | absolute value | abs(#) |
Formatting Printfprintf("%6d",123);
printf("%03d",5);
printf("%7.2f",6.789);
|
OUTPUTS WITHOUT SPACES
output: _ _ _ 1 2 3
output: 005
output: _ _ _ 6 . 7 9
| | Do While Loop (b)i=5;
do
{
printf(i);
i++;
}
while(i>3);
|
Executed 1+ times. Output: 5
While Loop (b)k=7;
while(k<5)
{
printf("%d", k);
k++;
}
|
Executed 0+ times. Output: (nothing)
Switch-Caseint dc;
scanf(“%lf”, dc);
switch(dc) //can only switch a non double/non float
{
case 0 : printf (“switch case statement 1”);
break;
case 1 : printf(“switch case statement 2”);
break;
default; //do default case, below this line
printf(“DEFAULT CASE”);
break;
}
|
Logical IfIf(logical expression)
{
//block of code
}
else
{
//statement if false
}
|
| | For Loop (a)for(i=0;i<10;i++) //INIT, TEST, LOOP ALTER
{
printf("%d",i); //BODY
}
|
Rewrite of While Loop (a)
While Loop (a)i=0; //INIT
while(i=0); //TEST
{
printf("%d",i); //BODY
i++; //LOOP ALTER
}
|
Pyramid Code Snippetfor(r=0;r<7;r++) //outer: 7 rows
{
for(s=0;s<r;s++) //controls spaces
{
printf(" ");
}
for(a=0;a<____*r;a++) //MATH
{
printf("*"); //controls stars
}
|
Pyramid Math1) Find m: m=(y2-y1)/(x2-x1)
2) Find equation: b=y=mx
3) Use equation in blank in code
*y=ANSWER
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets