Show Menu
Cheatography

exam 1 ece 160 Cheat Sheet (DRAFT) by

star codes

This is a draft cheat sheet. It is a work in progress and is not finished yet.

pyramid

#include <stdio.h>
int main()
{
// pyramid
    int i, j, k;
    for(i=1;i<=5;i++)
    {
        for(j=i;j<5;j++)
        {
            printf(" ");
        }
        for(k=1;k<(i*2);k++)
        {
                printf("*");
        }
        printf("\n");
    }
}

no 2 flipped

int main()
{
//  no 2 flipped
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=5;j>i;j--)
        {
            printf(" ");
        }
        for(k=1;k<=i;k++)
        {
            printf("*");
        }
        printf("\n");
    }
}
 

no 2 relfected

{
// no 2 relfected
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=1;j<i;j++)
        {
            printf(" ");
        }
        for(k=5;k>=i;k--)
        {
            printf("*");
        }
        printf("\n");
    }

    return 0;
}

upside down pyramid

int main()
{
// upside down pyramid
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=5;j>i;j--)
        {
                printf(" ");
        }
        for(k=1;k<(i*2);k++)
        {
                printf("*");
        }
        printf("\n");
    }
}
 

bizz buzz bozz

void main()
{
	int num;
	printf("Please enter a number. \nNumber:");
	scanf("%d",&num);
	int hund, ten, ones, mod;
	hund = num / 100;
	ten = num / 10 % 10;
	ones=num%10;
	mod=num%7;
	if(((hund==6)||(ten==6)||(ones==6)) && (mod==0))
		printf("bozz\n");
	else if(((hund==6)||(ten==6)||(ones==6)) && (mod!=0))
		printf ("buzz\n");
	else if(((hund!=6)||(ten!=6)||(ones!=6)) && (mod==0))
		printf("bizz\n");
	else
		printf("%d\n",num);
	printf("Thank you for playing bizz buzz bozz. You just won $1,000,000!");
}
 

stuff to know

int
-2,147­­,4­8­3,648 to +1,147­­,4­8­3,647
float
4bytes­­,c­o­ntain 1 digit/­­de­c­imal, +-10^38, 7digit­­sp­r­e­ci­­sion,f, illega­­lf­l­oats: 6.2.2f­­,6.-­­3f,6.2
double
8bytes­­,+­-­1­0^­­308­­,1­4­d­ig­­itp­­recise
types of c statements
declar­­at­i­o­ns­­/ar­­it­h­metic instru­­ct­i­o­ns­­/co­­ntrol instru­­ctions