Friday, 27 March 2009

Exer8Day

#include
#include

void main(){
clrscr();

int day;
printf("Enter an integer:");
scanf("%s",&day);
if(day==1);
printf("Sunday");
if(day==2)
printf("Monday");
else if(day==3)
printf("Tuesday");
else if(day==4)
printf("Wednesday");
else if(day==5)
printf("Thursday");
else if(day==6)
printf("Friday");
else if(day==7)
printf("Saturday");
else
printf("Day is not available!");
getch();
}

Sunday, 22 March 2009

Exercise7

#include
#include

int num1,num2,ans;
int operation;
void main(){
clrscr();
gotoxy(20,5);
printf("W\tE\tL\tC\tO\tM\tE"); gotoxy(30,7);textcolor(WHITE);cprintf("Enter Number 1:");
scanf("%d",&num1);
gotoxy(30,8);textcolor(WHITE);cprintf("Enter Number 2:");
scanf("%d",&num2);
gotoxy(24,10);textcolor(WHITE);cprintf("A.) Addition \n");
gotoxy(24,11);textcolor(WHITE);cprintf("B.) Subtraction \n");
gotoxy(24,12);textcolor(WHITE);cprintf("C.) Multiplication \n");
gotoxy(24,13);textcolor(WHITE);cprintf("D.) Division \n");
gotoxy(24,14);textcolor(WHITE);cprintf("Enter a Number above for the Operation:");
scanf("%d",&operation);
switch(operation)
{
case 1:
ans=num1+num2;
gotoxy(30,16);textcolor(WHITE);cprintf("The Answer is: %d",ans);
break;
case 2:
ans=num1-num2;
gotoxy(30,16);textcolor(WHITE);cprintf("The Answer is: %d",ans);
break;
case 3:
ans=num1*num2;
gotoxy(30,16);textcolor(WHITE);cprintf("The Answer is: %d",ans);
break;
case 4:
ans=num1/num2;
gotoxy(30,16);textcolor(WHITE);cprintf("The Answer is: %d",ans);
break;
default:
gotoxy(30,15);textcolor(WHITE+BLINK);cprintf("Invalid Number!! Try
Again!!");
}
getch();
}

Wednesday, 18 February 2009

Exercise6

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

clrscr();

nextscreen();nextscreen2();gotoxy(35,5);textcolor(RED);cprintf
("A] A D D I 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);sum=a+b;gotoxy(25,10);textcolor
(LIGHTGREEN+BLINK);cprintf("Sum of two number is: %
d",sum);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(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();nextscreen();nextscreen2();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);textcolo
r(GREEN);cprintf("Do you want to try again,y/n?");scanf("%
s",&z);menu();getch();break;
}switch(choice){case 'D':clrscr();nextscreen();nextscreen2
();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!");

}

}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(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();
nextscreen();nextscreen2();menu();getch();
}

Tuesday, 17 February 2009

Exercise5Grade

#include
#include

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

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

if(grade==-1)
{
printf("\n\n\n");
printf("\n\t\t\t Average is %.2f\n", average=sum/a);}
a++;
if(average>=95 && average<=100){printf("\n\n Rated of average:
A"):}else if (average>=90 && average: B");}else if (average>=89 && average <=90){ printf("\n\n Rated of this average:(");

}

getch();
}

Exercise4Pattern


#include<.h>
#include
void main()
{
int a, b, c;
int choice;

clrscr();
printf("\n Enter a number: ");
scanf("%d", &a);

printf("\n\t\t[A] - Pattern 1\n\n");
printf("\t\t[B] - Pattern 2\n\n");
printf("\t\t[C] - Pattern 3\n\n");
printf("\t\t[D] - Pattern 4\n\n");

printf("Select your choice: ");
scanf("%s",&choice);

switch (choice)
{
case 'A':
printf("\n ");
for(b=1; b<=a; b++)
{
for(c=1; c<=b; c++)
printf("*");
printf("\n ");
}
break;

case 'B':
printf("\n ");
for(c=a; c>=1; c--)
{
for(b=1; b<=c; b++)
printf("*");
printf("\n ");
}
break;

case 'C':
printf("\n ");
for(b=1; b<=a; b++)
{
for(c=1; c<=(a-b); c++)
printf(" ");
for(c=1; c<=b; c++)
printf("*");
printf("\n ");
}
break;

case 'D':
printf("\n ");
for(int b=a-1; b>=0; b--)
{
for(int c=b; c printf(" ");
for(int d=0; d<=b; d++)
printf("*");
printf("\n ");
}
break;


default:
clrscr();

printf("\n\n\n\n\t\t\tYour choice is not available!\n\n\n\n\t\t\tTry again later...!!!");


}

getch();
}



Sunday, 15 February 2009

Exercise3 Salary

#include
#include
int salary, years, bonus;
void main(){
clrscr();
printf("Enter Salary:");
scanf("%d",&salary);
printf("Enter Years of Service:");
scanf("%d",&years);
bonus=0;
bonus=salary*0.10;
printf("Bonus: %d ",bonus);}
else if ((years<=5) && (years>=2)){
bonus=salary*0.20;
printf("Bonus: %d", bonus);}
else if ((years<=10) && (years>=6)){
bonus=salary*0.50;
printf("Bonus: %d",bonus);}
else if (years<=11){
bonus=salary*0.75;
printf("Bonus: %d", bonus);}
getch();
}

Exercise2 Biography

#include
#include
void main(){
clrscr();
Printf("\t\t Hello I'm Marianne C.Tejamo, 16 years of age I am now first year college\n\n in University of Mindanao taking up BS Computer Science, and I'm recently preciding in Km6 Springtime Ave. Bangkal, I spare my time in playing with my pets and watchimg movies");
getch();
}