Thursday, February 12, 2009

Exercise 1

Output:



#include
#include

void main()
{
clrscr();
printf("\t\tH\ e\ L\ L\ o\ W\ O\ R\ L\ D!!\n\n");
printf("\n\n\n\t\tweLcomE to the FieLd of P\ R\ O\ G\ R\ A\ M\ M\ I\ N\ G!!\n\n\n\n\n");
printf("\t\t\t\tProgrammed by: Lady Mary-Anne P. Gorre ü");
getch();
}

Exercise 2

Output:




#include
#include

void main()
{

clrscr();

printf("\t\t\t\t>>My AutoBiography <<\n"); printf("\t\t\t\t I For onE\n\n"); printf("\nI'm Lady Mary-Anne P. Gorre. My friends used to call me langga, lady or paw, and also my family and relatives. But most of my friends in school used to call me\ngoregrind.\n\n I'm ingenuous girl, I play dota but not quite as often, I know where to place\nmyself--where should I belong and I am a choosy girl more often. "); printf("It's my\nobsession to eat every minute. Haha! (--,)\n\nI live in Davao literally, at Blk 22 Lot 15 Elenita Heights Subdivision."); printf("\n\n\n \t\t\t\t\t\t\tBetter know me! ;))"); getch(); }

Exercise 3

Output:


A-D




E


#include
#include


void main(){
clrscr();
int choice,a,b,n,y,sum=0,sub=0,mul=0,div=0;

gotoxy(30,4);textcolor(GREEN);cprintf("W E L C O M E ! ! !");


gotoxy(26,6);textcolor(LIGHTCYAN);cprintf("\nSelect operation you like to Try!");
gotoxy(25,8);textcolor(RED);cprintf("\n\t[A] for ADDITION");
gotoxy(25,9);textcolor(LIGHTRED);cprintf("\n\t[B] for SUBTRACTION");
gotoxy(25,10);textcolor(RED);cprintf("\n\t[C] for MULTIPLICATION");
gotoxy(25,11);textcolor(LIGHTRED);cprintf("\n\t[D] for DIVISION");
gotoxy(25,12);textcolor(RED);cprintf("\n\t[E] for Exit");
gotoxy(25,14);textcolor(LIGHTCYAN);cprintf("\nEnter your choice operation here:");
scanf("%s",&choice);
switch(choice)
{
case 'A':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
sum=a+b;
gotoxy(25,18);textcolor(GREEN);cprintf("Sum of two numbe is: %d",sum);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case 'B':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
sub=a-b;
gotoxy(25,18);textcolor(GREEN);cprintf("Sub of two numbe is: %d",sub);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case 'C':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
mul=a*b;
gotoxy(25,18);textcolor(GREEN);cprintf("Mul of two numbe is: %d",mul);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case 'D':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(RED);cprintf("Enter another number:");
scanf("%d",&b);
div=a/b;
gotoxy(25,18);textcolor(GREEN);cprintf("Div of two numbe is: %d",div);
gotoxy(25,19);textcolor(CYAN);cprintf("Nice onE!!");
break;
}
switch(choice)
{
case'E':
gotoxy(25,18);textcolor(YELLOW);cprintf("\n\nEnd of the program,Thank you very much!! ^_^");
printf("\n\n\t\t\t\t\tBy: Lady");
}
getch();
}

Exercise 4

Output



#include
#include

void main(){
clrscr();
int salary,years,bonus,sum;
printf("\n\tEnter employee 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 bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
break;
case 2:
bonus=0.20*salary;
sum=salary+bonus;
printf("\n\tEmployee bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
break;
case 3:
bonus=0.20*salary;
sum=salary+bonus;
printf("\n\tEmployee bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
break;
case 4:
bonus=0.10*salary;
sum=salary+bonus;
printf("\n\tEmployee bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
break;
case 5:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
break;
case 6:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
break;

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

case 10:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
break;
}
if(years>=11)
{
bonus=0.75*salary;
sum=salary+bonus;
printf("\n\tEmployee bonus is \"P%d",bonus);
printf("\n\nEmployee will receive a salary of \"P%d\"",sum);
}
printf("\n\n\t\t\" GooD JoB! KeeP UP the GooD WorK!! \"");
printf("\n\n\n\t\t\t\t\t \"Lady\"");
printf("\n\t\t\t\t\t""Programmer""");
getch();
}

Exercise 5

Output

A-D


#include
#include
#include

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

printf("\nEnter your favorite number:");
scanf("%d",&h);
printf("\nSelect pattern you like to appear!");
printf("\n\t[A] for Pattern 1");
printf("\n\t[B] for Pattern 2");
printf("\n\t[C] for Pattern 3");
printf("\n\t[D] for Pattern 4");
printf("\nEnter your choice Pattern here:");
scanf("%s",&choice);
switch(choice)
{
case 'A':
for(i=1,y=10;i<=h;i++,y++) { for(j=1,x=35;j<=i;j++,x++) { gotoxy(x,y); printf("*"); } } break; } switch(choice) { case 'B': for(i=1,y=10;i<=h;i++,y++) { for(j=1,x=35;j<=i;j++,x--) { gotoxy(x,y); printf("*"); } } break; } switch(choice) { case 'C': for(i=h,y=10;i<=h;i--,y++) { for(j=i,x=35;j>=1;j--,x++)
{
gotoxy(x,y);
printf("*");
}
}
break;
}
switch(choice)
{
case 'D':
for(i=h,y=10;i>=1;i--,y++)
{
for(j=i,x=35;j>=1;j--,x--)
{
gotoxy(x,y);
printf("*");
}
}
break;
}
printf("\n\nYou got a nice pattern! ;)) \n\nby:\n\n ¯ L a d y");
getch();
}

Exercise 6

Output:


#include
#include


void main()
{ clrscr();
float grade,average,sum;
int a=0;

while(grade!=-1)
{ sum=sum+grade;
textcolor(GREEN);cprintf("Enter grade: -1 to exit\n");
scanf("%f",&grade);


if(grade==-1)
{printf("\n
Average is %.2f\n",average=sum/a);}
a++;
}
if(average>=95 && average<=100){
printf("Rated A");}
else if(average>=90 && average<=94){
printf("Rated B");}
else if(average>=89 && average<=90){
printf("Rated C");}
textcolor(GREEN);cprintf("\n\n\ \ \Programmed by: Lady ü");

getch();
}

Exercise 7

Output


Getting started


A-B


C-D


E


#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(GREEN);cprintf("Í");
//delay (10);
gotoxy(2+x,21);textcolor(GREEN);cprintf("Í");
//delay (10);
}
for(y=1;y<=20;y++)
{
gotoxy(3,1+y);textcolor(GREEN);cprintf("º");
//delay (10);
gotoxy(79,1+y);textcolor(GREEN);cprintf("º");
//delay (10);
}
gotoxy(3,1);textcolor(GREEN);cprintf("É");
gotoxy(3,21);textcolor(GREEN);cprintf("È");
gotoxy(79,1);textcolor(GREEN);cprintf("»");
gotoxy(79,21);textcolor(GREEN);cprintf("¼");
}
void menu()
{
nextscreen();
nextscreen2();
int choice,a,b,n,y,sum=0,sub=0,mul=0,div=0,z;
gotoxy(30,2);textcolor(LIGHTRED);cprintf("Exercise VII");
gotoxy(30,5);textcolor(LIGHTGREEN);cprintf("WeLcomE!!");
gotoxy(26,6);textcolor(LIGHTRED);cprintf("\nSelect operation you like to Try!");
gotoxy(25,8);textcolor(YELLOW);cprintf("\n\t[A] for ADDITION");
gotoxy(25,9);textcolor(BLUE);cprintf("\n\t[B] for SUBTRACTION");
gotoxy(25,10);textcolor(CYAN);cprintf("\n\t[C] for MULTIPLICATION");
gotoxy(25,11);textcolor(RED);cprintf("\n\t[D] for DIVISION");
gotoxy(25,12);textcolor(GREEN);cprintf("\n\t[E] for Exit");
gotoxy(25,14);textcolor(YELLOW);cprintf("\nEnter your choice operation here:");
scanf("%s",&choice);

switch(choice)
{
case 'A':

clrscr();

nextscreen();
nextscreen2();
gotoxy(25,5);textcolor(CYAN);cprintf("A] Addition");
gotoxy(25,6);textcolor(CYAN);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(CYAN);cprintf("Enter 2nd number:");
scanf("%d",&b);
sum=a+b;
gotoxy(25,10);textcolor(CYAN);cprintf("Sum of two number is: %d",sum);
gotoxy(25,12);textcolor(CYAN);cprintf("NicE onE!!\n");
gotoxy(25,14);textcolor(CYAN);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] Subtraction");
gotoxy(25,6);textcolor(YELLOW);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(YELLOW);cprintf("Enter 2nd number:");
scanf("%d",&b);
sub=a-b;
gotoxy(25,10);textcolor(YELLOW);cprintf("Subtraction of two number is: %d",sub);
gotoxy(25,12);textcolor(YELLOW);cprintf("NicE onE!!");
gotoxy(25,14);textcolor(YELLOW);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(BLUE);cprintf("C] Multiplication");
gotoxy(25,6);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(BLUE);cprintf("Enter 2nd number:");
scanf("%d",&b);
mul=a*b;
gotoxy(25,10);textcolor(BLUE);cprintf("Muliplication of two number is: %d",mul);
gotoxy(25,12);textcolor(BLUE);cprintf("NicE onE!!");
gotoxy(25,14);textcolor(BLUE);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(RED);cprintf("D] Division");
gotoxy(25,6);textcolor(RED);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,8);textcolor(RED);cprintf("Enter 2nd number:");
scanf("%d",&b);
div=a/b;
gotoxy(25,10);textcolor(RED);cprintf("Division of two number is: %d",div);
gotoxy(25,12);textcolor(RED);cprintf("NicE onE!!");
gotoxy(25,14);textcolor(RED);cprintf("Do you want to try again,y/n?");
scanf("%s",&z);
menu();
getch();

break;
}



switch(choice)
{
case'E':

gotoxy(15,18);textcolor(LIGHTRED);cprintf("\n\nEnd of the program,Tinkchoi for browsing!! (-_-)");

}


}
void nextscreen2()

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

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

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

}