Tuesday, March 24, 2009

Exer8



#include
#include
#include
void menu();
void nextscreen();
void nextscreen2();

void nextscreen()
{
clrscr();
int x,y,z;
for(x=1;x<=77;x++)
{
gotoxy(2+x,1);textcolor(LIGHTBLUE);cprintf("Í");

gotoxy(2+x,21);textcolor(LIGHTBLUE);cprintf("Í");

}
for(y=1;y<=20;y++)
{
gotoxy(3,1+y);textcolor(LIGHTBLUE);cprintf("º");

gotoxy(79,1+y);textcolor(LIGHTBLUE);cprintf("º");

}
gotoxy(3,1);textcolor(RED);cprintf("É");
gotoxy(3,21);textcolor(RED);cprintf("È");
gotoxy(79,1);textcolor(RED);cprintf("»");
gotoxy(79,21);textcolor(RED);cprintf("¼");
}
void menu()
{ clrscr();
nextscreen();
nextscreen2();
int a,b,sum=0,sub=0,mul=0,div=0;

gotoxy(22,5);textcolor(LIGHTCYAN);cprintf("S I M P L E C A L C U L A T I O N ! ! !");
gotoxy(22,7);textcolor(LIGHTRED);cprintf("Enter first number:");
scanf("%d",&a);
gotoxy(22,8);textcolor(YELLOW);cprintf("Enter Second Number:");
scanf("%d",&b);
sum=a+b;
sub=a-b;
mul=a*b;
div=a/b;

gotoxy(25,11);textcolor(LIGHTRED);cprintf("The sum of two number is %d\n",sum);
gotoxy(25,12);textcolor(YELLOW);cprintf("The difference of two number is %d",sub);
gotoxy(25,13);textcolor(LIGHTBLUE);cprintf("The product of two number is %d",mul);
gotoxy(25,14);textcolor(CYAN);cprintf("The qoutient of two number is %d",div);


}
void nextscreen2()

{
clrscr();
int a,b,x,y,z;

for(x=1;x<=77;x++)
{
gotoxy(2+x,1);textcolor(YELLOW);cprintf("Í");
gotoxy(2+x,21);textcolor(YELLOW);cprintf("Í");
}
for(y=1;y<=20;y++){
gotoxy(3,1+y);textcolor(YELLOW);cprintf("º");
gotoxy(79,1+y);textcolor(YELLOW);cprintf("º");
}
gotoxy(3,1);textcolor(RED);cprintf("É");
gotoxy(3,21);textcolor(RED);cprintf("È");
gotoxy(79,1);textcolor(RED);cprintf("»");
gotoxy(79,21);textcolor(RED);cprintf("¼");
for(a=1;a<=49;a++)
{
gotoxy(15+a,4);textcolor(LIGHTBLUE);cprintf("°");
gotoxy(15+a,17);textcolor(LIGHTBLUE);cprintf("°");
}
for(b=1;b<=14;b++)
{
gotoxy(16,3+b);textcolor(LIGHTBLUE);cprintf("°");
gotoxy(65,3+b);textcolor(LIGHTBLUE);cprintf("° ");
}
}
void main()
{
clrscr();

nextscreen();
nextscreen2();
menu();
getch();

Exer7


#include
#include

void main(){
clrscr();
gotoxy(25,3);textcolor(RED+BLINK);cprintf(" B I O G R A P H Y ");
gotoxy(4,5);textcolor(LIGHTRED);cprintf("My name is Art E. Kilat.\n");
gotoxy(4,7);textcolor(BLUE);cprintf("I was born on November 3, 1991.\n");
gotoxy(4,9);textcolor(GREEN);cprintf("I live in Buhangin, Davao City.\n");
gotoxy(4,11);textcolor(CYAN);cprintf("My favorite color is red, white and blue.\n");
gotoxy(4,13);textcolor(YELLOW);cprintf("I love to spend my free time on playing computer games.\n");
gotoxy(4,15);textcolor(MAGENTA);cprintf("I am starting to like programming though it gives me headache for most of the time.\n");
getch();
}

Exer6



#include
#include
#define cp cprintf
#define s scanf

float salary, years, bonus;
void main()
{
clrscr();
gotoxy(25,9);textcolor(YELLOW);cp("Enter Salary: P");
s("%f", &salary);
gotoxy(25,10);textcolor(YELLOW);cp("\nEnter Years of Service: ");
s("%f", &years);
bonus=0;
if (years==1){
bonus=salary*0.10;
gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);
}
else if ((years<=5) && (years>=2)){
bonus=salary*0.20;
gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);
}
else if ((years<=10) && (years>=6)){
bonus=salary*0.50;
gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);
}
else if (years>=11){
bonus=salary*0.75;
gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);
}
getch();


}

Monday, March 23, 2009

Exer5




#include
#include
#include
#include

void nextscreen();
void nextscreen2();
void box();
void loop();


void main()
{
nextscreen();
nextscreen2();
getche();
}

void loop()
{
for(int i=1;i<=25;i++)
{
gotoxy(29+i,16);textcolor(RED);cprintf("Û");
delay(60);
}
for(int o=1;o<=25;o++)
{
gotoxy(29+o,16);textcolor(YELLOW);cprintf("°");
}
}
void nextscreen2()
{
clrscr();
int a,b,x,y,z,choice;

for(x=1;x<=77;x++)
{
gotoxy(2+x,1);textcolor(YELLOW);cprintf("Í");
gotoxy(2+x,21);textcolor(YELLOW);cprintf("Í");
}
for(y=1;y<=20;y++){
gotoxy(3,1+y);textcolor(YELLOW);cprintf("º");
gotoxy(79,1+y);textcolor(YELLOW);cprintf("º");
}
gotoxy(3,1);textcolor(YELLOW);cprintf("É");
gotoxy(3,21);textcolor(YELLOW);cprintf("È");
gotoxy(79,1);textcolor(YELLOW);cprintf("»");
gotoxy(79,21);textcolor(YELLOW);cprintf("¼");
for(a=1;a<=49;a++)
{
gotoxy(15+a,4);textcolor(CYAN);cprintf("ß");
gotoxy(15+a,17);textcolor(CYAN);cprintf("Ü");
}
for(b=1;b<=14;b++)
{
gotoxy(16,3+b);textcolor(CYAN);cprintf("Þ");
gotoxy(65,3+b);textcolor(CYAN);cprintf("Ý ");
}
gotoxy(35,3);textcolor(GREEN);cprintf("M E N U");
gotoxy(30,6);textcolor(GREEN);cprintf("[1] Addition ");
gotoxy(30,8);textcolor(GREEN);cprintf("[2] Subtraction");
gotoxy(30,10);textcolor(GREEN);cprintf("[3] Multplication");
gotoxy(30,12);textcolor(GREEN);cprintf("[4] Division");
gotoxy(30,14);textcolor(GREEN);cprintf("[5] Exit");
gotoxy(30,15);textcolor(YELLOW);cprintf("Plese make your choice:");
scanf("%d",&choice);
switch(choice){

case 1: float sum=0,x,y;
clrscr();
box();
gotoxy(30,7);textcolor(LIGHTRED);cprintf("Enter 1st number: ");
scanf("%f", &x);
gotoxy(30,8);textcolor(LIGHTRED);cprintf("Enter 2nd number: ");
scanf("%f", &y);
sum=x+y;
gotoxy(30,10);textcolor(YELLOW);cprintf("Sum is %f.", sum);
getche();nextscreen2();
break;

case 2: float dif=0,a,b;
clrscr();
box();
gotoxy(30,7);textcolor(LIGHTRED);cprintf("Enter 1st number: ");
scanf("%f", &a);
gotoxy(30,8);textcolor(LIGHTRED);cprintf("Enter 2nd number: ");
scanf("%f", &b);
dif=a-b;
gotoxy(30,10);textcolor(YELLOW);cprintf("Difference is %f.", dif);
getche();nextscreen2();
break;

case 3: float pro=0,c,d;
clrscr();
box();
gotoxy(30,7);textcolor(LIGHTRED);cprintf("Enter 1st number: ");
scanf("%f", &c);
gotoxy(30,8);textcolor(LIGHTRED);cprintf("Enter 2nd number: ");
scanf("%f", &d);
pro=c*d;
gotoxy(30,10);textcolor(YELLOW);cprintf("Product is %f.", pro);
getche();nextscreen2();
break;
case 4: float quo=0,e,f;
clrscr();
box();
gotoxy(30,7);textcolor(LIGHTRED);cprintf("Enter 1st number: ");
scanf("%f", &e);
gotoxy(30,8);textcolor(LIGHTRED);cprintf("Enter 2nd number: ");
scanf("%f", &f);
quo=e/f;
gotoxy(30,10);textcolor(YELLOW);cprintf("Quotient is %f.", quo);
getche();nextscreen2();
break;

case 5:
exit (0);nextscreen2();
break;

default: gotoxy(30,16);textcolor(WHITE);cprintf("Invalid input");
getche();nextscreen2();break;
}

getche();
}

void nextscreen()
{
clrscr();
int a,b,x,y,z;

for(x=1;x<=77;x++)
{
gotoxy(2+x,1);textcolor(YELLOW);cprintf("Í");
gotoxy(2+x,21);textcolor(YELLOW);cprintf("Í");
}
for(y=1;y<=20;y++){
gotoxy(3,1+y);textcolor(YELLOW);cprintf("º");
gotoxy(79,1+y);textcolor(YELLOW);cprintf("º");
}
gotoxy(3,1);textcolor(YELLOW);cprintf("É");
gotoxy(3,21);textcolor(YELLOW);cprintf("È");
gotoxy(79,1);textcolor(YELLOW);cprintf("»");
gotoxy(79,21);textcolor(YELLOW);cprintf("¼");
for(a=1;a<=49;a++)
{
gotoxy(15+a,4);textcolor(CYAN);cprintf("ß");
gotoxy(15+a,17);textcolor(CYAN);cprintf("Ü");
}
for(b=1;b<=14;b++)
{
gotoxy(16,3+b);textcolor(CYAN);cprintf("Þ");
gotoxy(65,3+b);textcolor(CYAN);cprintf("Ý ");
}
gotoxy(35,3);textcolor(GREEN);cprintf("W E L C O M E");
gotoxy(40,6);textcolor(GREEN);cprintf("T O");
gotoxy(30,8);textcolor(GREEN);cprintf("C S 1 2 1 ");
gotoxy(40,10);textcolor(GREEN);cprintf("P R O G R A M M I N G");
gotoxy(30,12);textcolor(GREEN);cprintf("W O R L D");
for(z=1;z<=25;z++){
gotoxy(29+z,16);textcolor(YELLOW);cprintf("ß");
}
gotoxy(28,15);textcolor(RED);cprintf("LOADING......");
for(int d=1;d<=5;d++)
{
loop();

}
}

void box()
{
clrscr();
int a,b,x,y,z;

for(x=1;x<=77;x++)
{
gotoxy(2+x,1);textcolor(YELLOW);cprintf("Í");
gotoxy(2+x,21);textcolor(YELLOW);cprintf("Í");
}
for(y=1;y<=20;y++){
gotoxy(3,1+y);textcolor(YELLOW);cprintf("º");
gotoxy(79,1+y);textcolor(YELLOW);cprintf("º");
}
gotoxy(3,1);textcolor(CYAN);cprintf("É");
gotoxy(3,21);textcolor(CYAN);cprintf("È");
gotoxy(79,1);textcolor(CYAN);cprintf("»");
gotoxy(79,21);textcolor(CYAN);cprintf("¼");
for(a=1;a<=49;a++)
{
gotoxy(15+a,4);textcolor(CYAN);cprintf("ß");
gotoxy(15+a,17);textcolor(CYAN);cprintf("Ü");
}
for(b=1;b<=14;b++)
{
gotoxy(16,3+b);textcolor(CYAN);cprintf("Þ");
gotoxy(65,3+b);textcolor(CYAN);cprintf("Ý ");
}
}

Exer4


#include
#include
#define p printf
#define s scanf

float grade, average, items, sum;
void main()
{
clrscr();
average=0;
sum=0;
do
{
p("Enter grade (-1 to exit): ");
s("%f", &grade);
if((grade!=-1)&&(grade<=100))
{
items++;
sum=sum+grade;
}
}while(grade!=-1);

average=sum/items;
p("Class Average: %.2f\n", average);

if((average>=95)&&(average<=100))
{
p("Rating: A");
}
else if((average>=90)&&(average<=94))
{
p("Rating: B");
}
else if((average>=85)&&(average<=89))
{
p("Rating: C");
}
else if((average>=80)&&(average<=84))
{
p("Rating: D");
}
else if((average>=75)&&(average<=79))
{
p("Rating: E");
}
else if(average<=74)
{
p("Rating: FAILED");
}

getch();
}

Exer3


#include
#include
#define p printf
#define s scanf


void main(){
char pattern;
clrscr();
p("A - Pattern 1 \n");
p("B - Pattern 2 \n");
p("C - Pattern 3 \n");
p("D - Pattern 4 \n");
p("Enter your letter of choice: ");
s("%c", &pattern);
switch (pattern)
{
case 'A':
p("");
gotoxy(37,15);
p("*");
gotoxy(37,16);
p("**");
gotoxy(37,17);
p("***");
gotoxy(37,18);
p("****");
gotoxy(37,19);
break;

case 'B':
p("");
gotoxy(37,15);
p("****");
gotoxy(37,16);
p("***");
gotoxy(37,17);
p("**");
gotoxy(37,18);
p("*");
gotoxy(37,19);
break;

case 'C':
p("");
gotoxy(37,15);
p(" *");
gotoxy(37,16);
p(" **");
gotoxy(37,17);
p(" ***");
gotoxy(37,18);
p("****");
gotoxy(37,19);
break;

case 'D':
p("");
gotoxy(37,15);
p("****");
gotoxy(37,16);
p(" ***");
gotoxy(37,17);
p(" **");
gotoxy(37,18);
p(" *");
gotoxy(37,19);
break;

}
getch();
}

Exer2


#include
#include
#define p printf
#define s scanf

float salary, years, bonus;
void main()
{
clrscr();
p("Enter Salary: P");
s("%f", &salary);
p("\nEnter Years of Service: ");
s("%f", &years);
bonus=0;
if (years==1){
bonus=salary*0.10;
p("\nBonus: P%.2f", bonus);
}
else if ((years<=5) && (years>=2)){
bonus=salary*0.20;
p("\nBonus: P%.2f", bonus);
}
else if ((years<=10) && (years>=6)){
bonus=salary*0.50;
p("\nBonus: P%.2f", bonus);
}
else if (years>=11){
bonus=salary*0.75;
p("\nBonus: P%.2f", bonus);
}
getch();