Wednesday, February 18, 2009

Exercises 7

ADDITION's OUTPUT:





SUBTRACTION's OUTPUT:






MULTIPLICATION's OUTPUT:





DIVISION's OUTPUT:





END'S OUTPUT:





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

}

Monday, February 16, 2009

Exercises 6




#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");
scanf("%f",&grade);

if(grade==-1)
{printf("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");} getch(); }

Tuesday, February 10, 2009

Exercises 5

Exer 5A

Exer 5A

Exer 5C

Exer 5D


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

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\nCreated by:\n\n ¯ May H. Torres");
getch();
}

Exercises 4

Exer 4

#include
#include

int salary, years, x=0,bonus=0;
void main(){
clrscr();
printf("\nEnter Salary:");
scanf("%d", &salary);
printf("\nEnter Years of Service:");
scanf("%d", &years);
if (years==1){
bonus=salary*0.10;
x=salary+bonus;
printf("\nBonus: %d", bonus);
printf("\nTotal Salary: %d",x);
}
else if ((years<=5) && (years>=2)){
bonus=salary*0.20;
x=salary+bonus;
printf("\nBonus: %d", bonus);
printf("\nTotal Salary: %d",x);
}
else if ((years<=10) && (years>=6)){
bonus=salary*0.50 ;
x=salary+bonus;
printf("\nBonus: %d", bonus);
printf("\nTotal Salary: %d",x);
}
else if (years<=11){
bonus=salary*0.75;
x=salary+bonus;
printf("\nBonus: %d", bonus);
printf("\nTotal Salary: %d",x);
}
printf("\n\n\n\n\t\t\t\t\t\tCreated by: May H. Torres");
getch();
}

Exercises 3

Exer 3A

Exer 3B

Exer 3C

Exer 3D

Exer 3E

#include
#include


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

printf("W E L C O M E ! ! !");
printf("\nSelect operation you like to Try!");
printf("\n\t[A] for ADDITION");
printf("\n\t[B] for SUBTRACTION");
printf("\n\t[C] for MULTIPLICATION");
printf("\n\t[D] for DIVISION");
printf("\n\t[E] for Exit");
printf("\nEnter your choice operation here:");
scanf("%s",&choice);
switch(choice)
{
case 'A':
printf("Enter number:");
scanf("%d",&a);
printf("Enter another number:");
scanf("%d",&b);
sum=a+b;
printf("Sum of two number is: %d",sum);
break;

case 'B':
printf("Enter number:");
scanf("%d",&a);
printf("Enter another number:");
scanf("%d",&b);
sub=a-b;
printf("Sub of two number is: %d",sub);
break;

case 'C':
printf("Enter number:");
scanf("%d",&a);
printf("Enter another number:");
scanf("%d",&b);
mul=a*b;
printf("Mul of two number is: %d",mul);
break;

case 'D':
printf("Enter number:");
scanf("%d",&a);
printf("Enter another number:");
scanf("%d",&b);
div=a/b;
printf("Div of two number is: %d",div);
break;

case'E':
printf("\n\nEnd of the program,\nThank you very much!!!! ");


}
printf("\n\n\t\t\t\t\t\tCreated by: May H. Torres");
getch();
}

Exercises 2

Exer 2

#include
#include

main()
{
clrscr();
printf("\n\n\t\t\t\tMy Autobiography ! ! \n\n\n");

printf("I am May H. Torres\n21years young,\nBorn on May 25, 1987,\nI am Serious but Funny \n");
printf("My house was located at Matina, Davao City together with my family\nI graduated at University of the Visayas located at Colon St. Cebu City");
printf("\n\n\n\t\tThank you for your reading!!!");
printf("\n\n\n\n\t\t\t\t\t\tCreated by: May H. Torres");
getch();
}

Exercises 1

Exer 1

#include
#include

main(){
clrscr();
printf("\n\n\n\n\t\t\t\tHello World!!");
printf("\n\n\t\t\t ____________________________");
printf("\n\n\n\n\n\t\t Welcome to the Programming Subject");
printf("\n\n\n\n\n\t\t\t\t\t\t Created by: May H. Torres");
getch();

}