Monday, February 16, 2009

Exer8


#include
#include


void main()
{
clrscr();
float sum,grade,average;
int a=0;
gotoxy(17,3);textcolor(WHITE);cprintf(" G R A D I N G S Y S T E M\n");
while(grade!=-1)
{sum=sum+grade;
printf("\nEnter grade;-1 to exit:");
scanf("%f",&grade);

if(grade==-1)
{printf("\nAverage is %.2f\n",average=sum/a);}
a++;
}
if(average>=95 && average<=100.00){ printf("\n\nRated of this average: A");} else if(average>=90 && average<=94.99){ printf("\n\nRated of this average: B");} else if(average>=85 && average<=89.99){ printf("\n\nRated of this average: C");} else if(average>=80 && average<=84.99){ printf("\n\nRated of this average: D");} else if(average>=75 && average<=79.99){ printf("\n\nRated of this average: E");} else if(average<74){>

Exer6


#include
#include

void main(){
clrscr();
int salary,years,bonus,sum;
gotoxy(30,5);textcolor(WHITE);cprintf("S A L A R Y");
gotoxy(20,6);textcolor(WHITE);cprintf("\nEnter employees Salary:");
scanf("%d",&salary);

gotoxy(20,7);textcolor(WHITE);cprintf("\nEnter years:");
scanf("%d",&years);

switch(years){

case 1:
bonus=0.10*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 2:
bonus=0.20*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 3:
bonus=0.20*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 4:
bonus=0.10*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 5:
bonus=0.50*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 6:
bonus=0.50*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;

case 7:
bonus=0.50*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 8:
bonus=0.50*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 9:
bonus=0.50*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;

case 10:
bonus=0.50*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
}
if(years>=11)
{
bonus=0.75*salary;
sum=salary+bonus;
gotoxy(20,8);textcolor(WHITE);cprintf("\nEmployee/s bonus is \"P%d",bonus);
gotoxy(20,9);textcolor(WHITE);cprintf("\nEmployee/s will receive a total salary of \"P%d\"",sum);
}


getch();
}

Thursday, February 5, 2009

Exer7


#include
#include
#include
#include
#include

void swtch();
void frme();
void ext();
void loop();
void loop1();
void main(){



clrscr();
frme();
loop1();
swtch();
getche();

}

void frme()
{

int x,y;
for(x=1;x<=77;x++){ gotoxy(1,1);textcolor(BLUE);cprintf("É"); gotoxy(1+x,1);textcolor(BLUE);cprintf("Í"); gotoxy(1+x,25);textcolor(BLUE);cprintf("Í"); gotoxy(1,25);textcolor(BLUE);cprintf("È"); } for(y=1;y<=23;y++){ gotoxy(1,1+y);textcolor(BLUE);cprintf("º"); gotoxy(78,1);textcolor(BLUE);cprintf("»"); gotoxy(78,1+y);textcolor(BLUE);cprintf("º"); gotoxy(78,25);textcolor(BLUE);cprintf("¼"); } for(x=5;x<=72;x++){ gotoxy(5,3);textcolor(BLUE);cprintf("É"); gotoxy(1+x,3);textcolor(BLUE);cprintf("Í"); gotoxy(1+x,22);textcolor(BLUE);cprintf("Í"); gotoxy(5,22);textcolor(BLUE);cprintf("È"); } for(y=1;y<=18;y++){ gotoxy(5,3+y);textcolor(BLUE);cprintf("º"); gotoxy(73,3);textcolor(BLUE);cprintf("»"); gotoxy(73,3+y);textcolor(BLUE);cprintf("º"); gotoxy(73,22);textcolor(BLUE);cprintf("¼"); } } void swtch() { clrscr(); frme(); _setcursortype(_NOCURSOR); int A,B,C,D,choice; char c[]={" W E L C O M E "}; for(int x=0;x
{
gotoxy(25+x,6);
textcolor(WHITE);
cprintf("%c",c[x]);
delay(40);
}
gotoxy(32,8);textcolor(WHITE);cprintf("[A]. ADDITION");
gotoxy(32,10);textcolor(WHITE);cprintf("[B]. SUBTRACTION");
gotoxy(32,12);textcolor(WHITE);cprintf("[C]. MULTIPLICATION");
gotoxy(32,14);textcolor(WHITE);cprintf("[D]. DIVISION");
gotoxy(32,16);textcolor(WHITE);cprintf("[E]. E X I T");
gotoxy(32,18);textcolor(WHITE);cprintf("Enter choice:");
scanf("%s",&choice);
switch(choice){
case 'A':
clrscr();
frme();
loop();
_setcursortype(_NOCURSOR);
int num1,num2,ans;
gotoxy(32,6);textcolor(WHITE+BLINK);cprintf("A D D I T I O N");
gotoxy(32,9);textcolor(BLUE);cprintf("Enter num1:");
scanf("%d",&num1);
gotoxy(32,11);textcolor(BLUE);cprintf("Enter num2:");
scanf("%d",&num2);
ans=num1+num2;
gotoxy(32,13);textcolor(WHITE);cprintf("Sum is: %d",ans);
getche();
clrscr();
frme();loop();
swtch();
break;


case 'B':
clrscr();
frme();loop();
_setcursortype(_NOCURSOR);
int e,s,diff;
gotoxy(30,6);textcolor(WHITE+BLINK);cprintf("S U B T R A C T I O N");
gotoxy(32,9);textcolor(BLUE);cprintf("Enter num1:");
scanf("%d",&e);
gotoxy(32,11);textcolor(BLUE);cprintf("Enter num2:");
scanf("%d",&s);
diff=e-s;
gotoxy(32,13);textcolor(WHITE);cprintf("Difference is: %d",diff);
getche();
clrscr();
frme(); loop();
swtch();
break;

case 'C':
clrscr();
frme();loop();
_setcursortype(_NOCURSOR);
int l,k,prod;
gotoxy(30,6);textcolor(WHITE+BLINK);cprintf("M U L T I P L I C A T I O N");
gotoxy(32,9);textcolor(BLUE);cprintf("Enter num1:");
scanf("%d",&l);
gotoxy(32,11);textcolor(BLUE);cprintf("Enter num2:");
scanf("%d",&k);
prod=l*k;
gotoxy(32,13);textcolor(WHITE);cprintf("Product is: %d",prod);
getche();
clrscr();
loop();
frme();
swtch();
break;

case 'D':
clrscr();
frme();loop();
_setcursortype(_NOCURSOR);
int o,u,quo;
gotoxy(34,6);textcolor(WHITE+BLINK);cprintf("D I V I S I O N");
gotoxy(32,9);textcolor(BLUE);cprintf("Enter num1:");
scanf("%d",&o);
gotoxy(32,11);textcolor(BLUE);cprintf("Enter num2:");
scanf("%d",&u);
quo=o/u;
gotoxy(32,13);textcolor(WHITE);cprintf("Quotient is: %d",quo);
getche();
clrscr();
frme(); loop();
swtch();
break;

case 'E':
clrscr();frme(); _setcursortype(_NOCURSOR);
loop1();
ext();
exit(0);
getche();
break;


default:
clrscr();
frme(); loop();
_setcursortype(_NOCURSOR);
char c[]={" I N V A L I D I N P U T ! ! "};
for(int x=0;x
{
gotoxy(24+x,12);
textcolor(WHITE);
cprintf("%c",c[x]);
delay(40);
}
}
clrscr();
frme();loop();
swtch();
}
void ext()
{
clrscr();
_setcursortype(_NOCURSOR);
int l,m;
for(l=1;l<=65;l++) { gotoxy(6+l,7);printf("ì"); gotoxy(72-l,18);printf("ì"); delay(20); } _setcursortype(_SOLIDCURSOR); char c[]={" Logging out, Thankyou!!! "}; for(int x=0;x
{
gotoxy(25+x,11);
textcolor(9);
cprintf("%c",c[x]);
normvideo();
delay(40);
}
{

}
}
void loop()
{
_setcursortype(_NOCURSOR);
for(int e=0;e<=25;e++){ gotoxy(5+e,23);textcolor(YELLOW);cprintf("¯"); } for(int i=0;(i<=25*4);i++) { gotoxy(5+(i/4),23);textcolor(RED);cprintf("¯"); gotoxy(5,24);textcolor(6);cprintf("%d%",i); delay(10); } for(int o=0;o<=25;o++) { gotoxy(5+o,23);textcolor(YELLOW);cprintf("¯"); } } void loop1() { _setcursortype(_NOCURSOR); for(int e=0;e<=25;e++){ gotoxy(5+e,23);textcolor(YELLOW);cprintf("¯"); } gotoxy(8,24);textcolor(WHITE+BLINK);cprintf("LOADING......"); for(int i=0;(i<=25*4);i++) { gotoxy(5+(i/4),23);textcolor(RED);cprintf("¯"); gotoxy(5,24);textcolor(6);cprintf("%d%",i); delay(15); } for(int o=0;o<=25;o++) { gotoxy(5+o,23);textcolor(YELLOW);cprintf("¯"); } }

Exer4


#include
#include

void main(){
clrscr();
int salary,years,bonus,sum;
printf("\n\tEnter employees Salary here:");
scanf("%d",&salary);

printf("\n\tEnter years:");
scanf("%d",&years);

switch(years){

case 1:
bonus=0.10*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 2:
bonus=0.20*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 3:
bonus=0.20*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 4:
bonus=0.10*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 5:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 6:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;

case 7:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 8:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
case 9:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;

case 10:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
}
if(years>=11)
{
bonus=0.75*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
}


getch();
}

Exer3


#include
#include


int i,j,x,y,A,B,C,D,pattern;
void main()
{
clrscr();

printf("\n\t[A]Enter Pattern 1");
printf("\n\t[B]Enter Pattern 2");
printf("\n\t[C]Enter Pattern 3");
printf("\n\t[D]Enter Pattern 4");
printf("\n\tEnter Pattern:");
scanf("%s",&pattern);

switch(pattern)
case 'A':
for(i=1,y=8;i<=4;i++,y++) { for(j=1,x=35;j<=i;j++,x++) { gotoxy(x,y); printf("*"); }} switch(pattern) case 'B': for(i=1,y=8;i<=4;i++,y++) { for(j=1,x=35;j<=i;j++,x--) { gotoxy(x,y); printf("*"); } } switch(pattern) case 'C': for(i=4,y=8;i<=4;i--,y++) { for(j=i,x=35;j>=1;j--,x++)
{
gotoxy(x,y);
printf("*");
}
}
switch(pattern)
case 'D':
for(i=4,y=8;i>=1;i--,y++)
{
for(j=i,x=35;j>=1;j--,x--)
{
gotoxy(x,y);
printf("*");
}}
getch();
}

Exer2


#include
#include

void main()
{

clrscr();

gotoxy(25,5); printf("***** My AutoBiography *****");
printf("\n\nIm Bonnie M. Darudnay 27 years of age, born on 30th day of November,1981.\nCurrently residing in U.M. Site, Matina Davao City.\nI like to play computer games, hang-out with my friends and spend more \ntime to my loved one:-). Most of my friends preffered to call me HANGAL\n which makes my name to be more popular. I joined an organization last 2005\n which is the Philippine Guardians Brotherhood, inc.\n BATUSAI is my pseudonym in PGBI.");
printf("I am currently studying here in\n University of Mindanao, taking up BS-Information technology.");

getch();
}

Exer1


#include
#include

void main()
{

clrscr();

printf("HELLO WORLD!\n");

getch();
}