Saturday, March 28, 2009

EXERCISE8



#include

#include

void menu();

{

clrscr();int a,y,z;

for(int a=1;a<=75;a++){

textbackground(MAGENTA);

gotoxy(2+x,1);textcolor(RED);cprintf("Í");

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

}

for(y=1;y<=20;y++){

gotoxy(3,1+y);textcolor(RED);cprintf("º");

gotoxy(79,1+y);textcolor(RED);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()

{

int choice,a,b,n,y,z;

sum=0;

sub=0;

mul=0;

div=0;

gotoxy(26,6);textcolor(RED);cprintf("\nSelect operation:");

gotoxy(25,8);textcolor(PINK);cprintf("\n\t[A] for ADDITION");

gotoxy(25,9);textcolor(PINK);cprintf("\n\t[B] for SUBTRACTION");

gotoxy(25,10);textcolor(PINK);cprintf("\n\t[C] for MULTIPLICATION");

gotoxy(25,11);textcolor(PINK);cprintf("\n\t[D] for DIVISION");

gotoxy(25,12);textcolor(PINK);cprintf("\n\t[E] for EXIT");

gotoxy(25,14);textcolor(PINK);cprintf("\nEnter choice here:");scanf("%s",&choice);

switch(choice)

{

case 'A':
clrscr();

gotoxy(35,5);textcolor(BLACK);cprintf("A] A D D I T I O N");

gotoxy(25,7);textcolor(PINK);cprintf("Enter number:");scanf("%d",&a);

gotoxy(25,8);textcolor(PINK);cprintf("Enter another number:");scanf("%d",&b);sum=a+b;

gotoxy(25,10);textcolor(BLACK);cprintf("Sum of two number is: %d",sum);

gotoxy(25,14);textcolor(BLACK);cprintf("Do you want to try again,y/n?");scanf("%s",&z);

menu();

getch();

break;
}

switch(choice)

{

case 'B':

clrscr();

gotoxy(35,5);textcolor(YELLOW);cprintf("B] S U B T R A C T I O N");

gotoxy(25,7);textcolor(LIGHTRED);cprintf("Enter number:");scanf("%d",&a);

gotoxy(25,8);textcolor(LIGHTRED);cprintf("Enter another number:");scanf("%d",&b);sub=a-b;

gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("DIFFERENCE of two number is: %d",sub);

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

gotoxy(35,5);textcolor(YELLOW);cprintf("C] M U L T I P L I C A T I O N");

gotoxy(25,7);textcolor(LIGHTRED);cprintf("Enter number:");scanf("%d",&a);

gotoxy(25,8);textcolor(LIGHTRED);cprintf("Enter another number:");scanf("%d",&b);mul=a*b;

gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("PRODUCT of two number is: %d",mul);

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

gotoxy(35,5);textcolor(YELLOW);cprintf("D] D I V I S I O N");

gotoxy(25,7);textcolor(LIGHTRED);cprintf("Enter number:");scanf("%d",&a);

gotoxy(25,8);textcolor(LIGHTRED);cprintf("Enter another number:");scanf("%d",&b);div=a/b;

gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("QOUTIENT of two number is: %d",div);

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(15,18);textcolor(LIGHTCYAN);cprintf("\n\nThe program ends here.. THANK YOU!");
}
}

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(LIGHTCYAN);cprintf("É");

gotoxy(3,21);textcolor(LIGHTCYAN);cprintf("È");

gotoxy(79,1);textcolor(LIGHTCYAN);cprintf("»");

gotoxy(79,21);textcolor(LIGHTCYAN);cprintf("¼");

for(a=1;a<=49;a++)

{

gotoxy(15+a,4);textcolor(LIGHTCYAN);cprintf("ß");

gotoxy(15+a,17);textcolor(LIGHTCYAN);cprintf("Ü");}

for(b=1;b<=14;b++){

gotoxy(16,3+b);textcolor(LIGHTCYAN);cprintf("°");

gotoxy(65,3+b);textcolor(LIGHTCYAN);cprintf("° ");

}

}

void main()

{

clrscr();
menu();getch();
}



Monday, February 16, 2009

EXERCISE7




























#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(RED);cprintf("Í");
delay (10);
gotoxy(2+x,21);textcolor(RED);cprintf("Í");
delay (10);
}
for(y=1;y<=20;y++)
{
gotoxy(3,1+y);textcolor(RED);cprintf("º");
delay (10);
gotoxy(79,1+y);textcolor(RED);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,subtraction=0,multiplication=0,division=0,z;
gotoxy(30,5);textcolor(YELLOW);cprintf("W E L C O M E ! ! !");
gotoxy(26,6);textcolor(YELLOW);cprintf("Select operation you like to Try!");
gotoxy(25,8);textcolor(YELLOW+BLINK);cprintf("[A] for the ADDITION");
gotoxy(25,9);textcolor(GREEN);cprintf("[B] for the SUBTRACTION");
gotoxy(25,10);textcolor(LIGHTMAGENTA+BLINK);cprintf("[C] for the MULTIPLICATION");
gotoxy(25,11);textcolor(LIGHTBLUE);cprintf("[D] for the DIVISION");
gotoxy(25,12);textcolor(RED+BLINK);cprintf("[E] for the Exit");
getch();
clrscr();
gotoxy(25,14);textcolor(CYAN);cprintf("Enter 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/s:");
scanf("%d",&a);

gotoxy(25,8);textcolor(BLUE);cprintf("Enter other number/s:");
scanf("%d",&b);
sum=a+b;
gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("The Sum of two numbers is: %d",sum);
gotoxy(25,12);textcolor(CYAN);cprintf("W O W !!!\n");
gotoxy(25,14);textcolor(LIGHTBLUE);cprintf("You want to try the others?");
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/s:");
scanf("%d",&a);
gotoxy(25,8);textcolor(LIGHTCYAN);cprintf("Enter other number/s:");
scanf("%d",&b);

subtraction=a-b;
gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf(" The Subtraction of two numbers is: %d",subtraction);
gotoxy(25,12);textcolor(CYAN);cprintf("W O W !!!");
gotoxy(25,14);textcolor(LIGHTBLUE);cprintf("You want to try the others?");
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/s:");
scanf("%d",&a);
gotoxy(25,8);textcolor(BLUE);cprintf("Enter other number/s:");
scanf("%d",&b);
multiplication=a*b;
gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("The Muliplication of two number is: %d",multiplication);
gotoxy(25,12);textcolor(CYAN);cprintf("W O W !!!");
gotoxy(25,14);textcolor(GREEN);cprintf("You want to try the others?");
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/s:");
scanf("%d",&a);
gotoxy(25,8);textcolor(LIGHTCYAN);cprintf("Enter other number/s:");
scanf("%d",&b);
division=a/b;
gotoxy(25,10);textcolor(YELLOW+BLINK);cprintf("The Division of two numbers is: %d",division);
gotoxy(25,12);textcolor(CYAN);cprintf("W O W !!!");
gotoxy(25,14);textcolor(LIGHTGREEN);cprintf("You want to try the others?");
scanf("%s",&z);
menu();
getch();

break;
}



switch(choice)
{
case'E':
getch();
clrscr();
gotoxy(15,18);textcolor(CYAN);cprintf("Thank you!!! GOD BLESS!!!Bye...Bye...Bye...");

}


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

}

EXERCISE6














#include
#include

void main(){
clrscr();
int x,y;
printf("Enter Integer:");
scanf("%d",&x);
for(y=1;y<=x;y++){
printf("%d\n",y);}
getch();
}

EXERCISE5















#include
#include

void main()
{
clrscr();
int a,b,grade,sum,x,subject;
float average;
printf("Enter your Subject:");
scanf("%s",&subject);
printf("Enter grade,-1 to exit:");
scanf("%d",&grade);
if(grade!=-1 && grade>=95 && grade<=100)
{
printf("Enter grade;-1 to exit:");
scanf("%d",&a);
sum=grade+a;
average=sum/2;
printf("Average is %.2f\n",average);
printf("Rated A");
}
if(grade!=-1 && grade>=90 && grade<=94)
{
printf("Enter grade;-1 to exit:");
scanf("%d",&a);
sum=grade+a;
average=sum/2;
printf("Average is %.2f\n",average);
printf("Rated B");
}
if(grade!=-1 && grade>=85 && grade<=89)
{
printf("Enter grade;-1 to exit:");
scanf("%d",&a);
sum=grade+a;
average=sum/2;
printf("Average is %.2f\n",average);
printf("Rated C");
}
if(grade!=-1 && grade>=80 && grade<=84)
{
printf("Enter grade;-1 to exit:");
scanf("%d",&a);
sum=grade+a;
average=sum/2;
printf("Average is %.2f\n",average);
printf("Rated D");
}
if(grade!=-1 && grade>=75 && grade<=79)
{
printf("Enter grade;-1 to exit:");
scanf("%d",&a);
sum=grade+a;
average=sum/2;
printf("Average is %.2f\n",average);
printf("Rated E");
}
if(grade!=-1 && grade<=74)
{
printf("SORRY YOUR FAILED IN THIS SUBJECT");
}
else
{
if(grade==-x)
printf("\"INVALID INPUT\"");
}
while(grade==-1)
{
printf("NO NUMBERS INPUTTED");}
getch();
}

EXERCISE4



#include
#include
#include

void main(){
clrscr();
int h,i,j,x,y,choice,X;


getch();
clrscr();
gotoxy(25,4);textcolor(LIGHTRED);cprintf("\nEnter your favorite number:");
textcolor(WHITE);scanf("%d",&h);
getch();
clrscr();
gotoxy(25,5);textcolor(CYAN);cprintf("\nSelect pattern you like to appear!");
gotoxy(25,7);textcolor(BLUE);cprintf("\n\t[A] for Pattern 1");
gotoxy(25,8);textcolor(DARKGRAY);cprintf("\n\t[N] for Pattern 2");
gotoxy(25,9);textcolor(LIGHTGREEN);cprintf("\n\t[I] for Pattern 3");
gotoxy(25,10);textcolor(YELLOW);cprintf("\n\t[T] for Pattern 4");
gotoxy(25,12);textcolor(RED);cprintf("\nEnter your choice Pattern here:");
textcolor(WHITE);scanf("%s",&choice);
getch();
clrscr();
switch(choice)
{
case 'A':
for(i=1,y=15;i<=h;i++,y++)
{
for(j=1,x=40;j<=i;j++,x++)
{
gotoxy(x,y);
printf("*");
}
}
break;
}
getch();
clrscr();
switch(choice)
{
case 'N':
for(i=1,y=15;i<=h;i++,y++)
{
for(j=1,x=40;j<=i;j++,x--)
{
gotoxy(x,y);
printf("*");
}
}
break;
}
getch();
clrscr();
switch(choice)
{
case 'I':
for(i=h,y=15;i<=h;i--,y++)
{
for(j=i,x=40;j>=1;j--,x++)
{
gotoxy(x,y);
printf("*");
}
}
break;
}
getch();
clrscr();
switch(choice)
{
case 'T':
for(i=h,y=15;i>=1;i--,y++)
{
for(j=i,x=40;j>=1;j--,x--)
{
gotoxy(x,y);
printf("*");
}
}
break;
}


gotoxy(5,20);textcolor(MAGENTA);cprintf("thank you for your choice the pattern...,see you!!!!bye...bye...bye...");
getch();
}

EXERCISE2



#include
#include

void main()
{
clrscr();
char Name[10];
char Nname [10];
char Address[20];
char Bday[20];
char School[8];
char Course[5];
char Year[10];
char describe[100];

gotoxy(32,10);printf("M Y");
gotoxy(22,12);printf("A U T O B I O G R A P H Y");

getch();
clrscr();
textcolor (GREEN);
textbackground (WHITE);
gotoxy(25,11);cprintf("Name:");
gets(Name);
gotoxy(25,13);cprintf("N-name:");
gets(Nname);
gotoxy(25,15);cprintf("Address:");
gets(Address);
gotoxy(25,17);cprintf("B-day:");
gets(Bday);
gotoxy(25,19);cprintf("School:");
gets(School);
gotoxy(25,21);cprintf("Course:");
gets(Course);
gotoxy(25,23);cprintf("Year:");
gets(Year);
gotoxy(25,25);cprintf("Describe your self:");
gets(describe);

getch();
clrscr();
textcolor (BLUE);
textbackground (WHITE);
gotoxy(20,10);cprintf("I am %s \n",Name);
gotoxy(20,12);cprintf("Some of my friends call me %s\n",Nname);
gotoxy(20,14);cprintf("I came from %s\n",Address);
gotoxy(20,16);cprintf("My Bday is %s\n",Bday);
gotoxy(20,18);cprintf("I am studying in %s\n",School);
gotoxy(20,20);cprintf("I am taking up %s\n",Course);
gotoxy(20,22);cprintf("I am %s\n",Year);
gotoxy(20,24);cprintf("and I am a ",describe);
getch();
clrscr();
textcolor(RED);
textbackground(WHITE);
gotoxy(20,2);cprintf(" $$");
gotoxy(20,3);cprintf(" $ $ ");
gotoxy(20,4);cprintf(" $ $$$ $ $ $$$ $ ");
gotoxy(20,5);cprintf(" $ $ $ $ $ $ ");
gotoxy(20,6);cprintf(" $ $ $ $ $ $ ");
gotoxy(20,7);cprintf(" $ $ $ $ $ $ ");
gotoxy(20,8);cprintf(" $$$ $ $ $$$$$$$$$ $ $ $$$ ");
gotoxy(20,9);cprintf(" $ $ $$$$$$$$ $ $ ");
gotoxy(20,10);cprintf(" $ $$$$$$ $ ");
gotoxy(20,11);cprintf(" $ $ $$ $ $ ");
gotoxy(20,12);cprintf(" $ $ $$ $ $ ");
gotoxy(20,13);cprintf(" $ $ $$ $ $ ");
gotoxy(20,14);cprintf(" $ $ $ $$ $ $ $ ");
gotoxy(20,15);cprintf(" $$");
gotoxy(20,16);cprintf(" $$");
gotoxy(20,17);cprintf(" $$");
gotoxy(20,18);cprintf(" $$");
gotoxy(20,19);cprintf(" $$");
gotoxy(20,20);cprintf(" $$");
gotoxy(20,21);cprintf(" $$");
gotoxy(20,22);cprintf(" $$");
gotoxy(20,23);cprintf(" $$");
gotoxy(20,24);cprintf(" $$");


getch();
}

EXERCISE3
























#include
#include

void main()
{
clrscr();
int Salary,Years,Bonus,Sum;
printf("\n\tEnter Employe Salary:");
scanf("%d",& Salary);

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

switch(Years){

case 1:
Bonus=0.10*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees Bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
case 2:
Bonus=0.20*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees Bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
case 3:
Bonus=0.20*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
case 4:
Bonus=0.10*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
case 5:
Bonus=0.50*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
case 6:
Bonus=0.50*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;

case 7:
Bonus=0.50*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
case 8:
Bonus=0.50*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
case 9:
Bonus=0.50*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;

case 10:
Bonus=0.50*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\nEmployees will receive a salary of \"P%d\"",Sum);
break;
}
if(Years>=11)
{
Bonus=0.75*Salary;
Sum=Salary+Bonus;
printf("\n\tEmployees bonus is \"P%d",Bonus);
printf("\n\n\tEmployees will receive a salary of \"P%d\"",Sum);
}
printf("\n\n\t\tGOOD JOB!! KEEP UP THE GOOD WORK!!! ");


getch();
}