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,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 |
types of c statements |
declarations/arithmetic instructions/control instructions |
|