Thursday, February 5, 2009

My exercises In our Programming



This is our exercise 1

#include
#include

void main()

{

clrscr();

printf("HELLO WORLD!\n");

getch();

}


Output:














This is exercise 2


#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 Univers
ity of Mindanao, taking up BS-Information technology.");

getch();
}



Output:













This is exercise 3


#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();

}

Output:














This
is exercise 4


#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 sal
ary 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\tEmploye
e/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 b
onus 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+bon
us;
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\nEmploy
ee/s will receive a salary of \"P%d\"",sum);
}


getch();
}



Output:













This is exercise 5


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

int x,grade,ave,a,b,c;



void main()
{
clrscr();
p("Enter grade, -1 to exit:");
s("%d",&a);
p("Enter grade, -1 to exit:");
s("%d",&b);
p("Enter grade, -1 to exit:");

s("%d",&c);
grade=a+b+c;
ave=grade/3;
p("class average:%d",ave);

if(ave<=9) p("\ninvalid input"); while (ave>=95)
p("");


getch();
}


Output:



















This is exercise 6


#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);cprin
tf("È"); } 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


Output:

















exercise # 7

#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(LIGHTCYAN);cprintf("Í"); //delay (10); gotoxy(2+x,21);textcolor(LIGHTCYAN);cprintf("Í"); //delay (10); } for(y=1;y<=20;y++) { gotoxy(3,1+y);textcolor(LIGHTCYAN);cprintf("º"); //delay (10); gotoxy(79,1+y);textcolor(LIGHTCYAN);cprintf("º"); //delay (10); } 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() { nextscreen(); nextscreen2(); int choice,a,b,n,y,sum=0,sub=0,mul=0,div=0,z; gotoxy(30,2);textcolor(YELLOW);cprintf("E X E R C I S E 7"); gotoxy(30,5);textcolor(LIGHTRED);cprintf("W E L C O M E ! ! !"); gotoxy(26,6);textcolor(CYAN);cprintf("\nSelect operation you like to Try!"); gotoxy(25,8);textcolor(YELLOW+BLINK);cprintf("\n\t[A] for ADDITION"); gotoxy(25,9);textcolor(GREEN);cprintf("\n\t[B] for SUBTRACTION"); gotoxy(25,10);textcolor(LIGHTMAGENTA+BLINK);cprintf("\n\t[C] for MULTIPLICATION"); gotoxy(25,11);textcolor(LIGHTBLUE);cprintf("\n\t[D] for DIVISION"); gotoxy(25,12);textcolor(RED+BLINK);cprintf("\n\t[E] for Exit"); gotoxy(25,14);textcolor(CYAN);cprintf("\nEnter your choice operation here:"); scanf("%s",&choice); switch(choice) { case 'A': clrscr(); nextscreen(); nextscreen2(); gotoxy(25,5);textcolor(RED);cprintf("A] A D D I T I O N"); gotoxy(25,6);textcolor(RED);cprintf("Enter number:"); scanf("%d",&a); gotoxy(25,8);textcolor(BLUE);cprintf("Enter another number:"); scanf("%d",&b); sum=a+b; gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("Sum of two number is: %d",sum); gotoxy(25,12);textcolor(CYAN);cprintf("NICE ONE!!!!!!!!!!\n"); gotoxy(25,14);textcolor(LIGHTBLUE);cprintf("Do you want to try again,y/n?"); scanf("%s",&z); menu(); getch(); break; } switch(choice) { case 'B': clrscr(); nextscreen(); nextscreen2(); gotoxy(25,5);textcolor(YELLOW);cprintf("B] S U B T R A C T I O N"); gotoxy(25,6);textcolor(RED);cprintf("Enter number:"); scanf("%d",&a); gotoxy(25,8);textcolor(LIGHTCYAN);cprintf("Enter another number:"); scanf("%d",&b); sub=a-b; gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("Subtraction of two number is: %d",sub); gotoxy(25,12);textcolor(CYAN);cprintf("NICE ONE!!!!!!!!!!"); gotoxy(25,14);textcolor(LIGHTBLUE);cprintf("Do you want to try again,y/n?"); scanf("%s",&z); menu(); getch(); break; } switch(choice) { case 'C': clrscr(); nextscreen(); nextscreen2(); gotoxy(25,5);textcolor(YELLOW);cprintf("C] M U L T I P L I C A T I O N"); gotoxy(25,6);textcolor(RED);cprintf("Enter number:"); scanf("%d",&a); gotoxy(25,8);textcolor(BLUE);cprintf("Enter another number:"); scanf("%d",&b); mul=a*b; gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("Muliplication of two number is: %d",mul); gotoxy(25,12);textcolor(CYAN);cprintf("NICE ONE!!!!!!!!!!"); gotoxy(25,14);textcolor(GREEN);cprintf("Do you want to try again,y/n?"); scanf("%s",&z); menu(); getch(); break; } switch(choice) { case 'D': clrscr(); nextscreen(); nextscreen2(); gotoxy(25,5);textcolor(YELLOW);cprintf("D] D I V I S I O N"); gotoxy(25,6);textcolor(LIGHTRED);cprintf("Enter number:"); scanf("%d",&a); gotoxy(25,8);textcolor(LIGHTCYAN);cprintf("Enter another number:"); scanf("%d",&b); div=a/b; gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("Division of two number is: %d",div); gotoxy(25,12);textcolor(CYAN);cprintf("NICE ONE!!!!!!!!!!"); gotoxy(25,14);textcolor(LIGHTGREEN);cprintf("Do you want to try again,y/n?"); scanf("%s",&z); menu(); getch(); break; } switch(choice) { case'E': gotoxy(25,18);textcolor(WHITE+BLINK);cprintf("Originated by: \"Richard C. Aguillon\""); gotoxy(15,18);textcolor(CYAN);cprintf("\n\nEnd of the program,Thankyou very much!!!! har har har har...."); } } void nextscreen2() { clrscr(); int a,b,x,y,z; for(x=1;x<=77;x++) { gotoxy(2+x,1);textcolor(LIGHTCYAN);cprintf("Í"); gotoxy(2+x,21);textcolor(LIGHTCYAN);cprintf("Í"); } for(y=1;y<=20;y++){ gotoxy(3,1+y);textcolor(LIGHTCYAN);cprintf("º"); gotoxy(79,1+y);textcolor(LIGHTCYAN);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(); }


Output:














exercise #8

#include
#include


void main()
{
clrscr();
float sum,grade,average;
int a=0;
gotoxy(17,3);textcolor(WHITE);cprintf("E X E R C I S E # 8/ 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){>

Output: