Tuesday, February 17, 2009

EXER 1











#include
#include
main(){clrscr();gotoxy(20,9);
printf("WELCOME TO THE WORLD OF PROGRAMING");
getch();}

EXER 2


#include
#include
void main(){clrscr();gotoxy(10,7);printf("MY AUTOBIOGRAPHY");gotoxy(10,9);printf("My life as a human being is never beeen interesting\n");printf("That is my opinion\nI was born on April 27, 1989 where my name came from\n");printf("My mother was a secodary high school teacher\nwhile my fater was a farmer\n");printf("We live in a Tulunan North Cotabato\there we live a simple life\n");printf("I have three sibling. I was the second child in the family\n");printf("My older sister was a graduate of BS in Nursing\n");printf("While my two younger brother are in secondary and elementary level\n");printf("I am currently taking BS in Information in Technology in\nUniversity of Mindanao");getch();}

Monday, February 16, 2009

EXER 3


#include
#include
float num1,num2,sum=0,diff=0,pro=0,quo=0;void main(){clrscr();gotoxy(25,4);textcolor(YELLOW);cprintf("Basic Operations\n\n");gotoxy(12,7);textcolor(GREEN);cprintf("Enter 1st number:");scanf("%f", &num1);gotoxy(12,8);textcolor(GREEN);cprintf("Enter 2nd number:");scanf("%f", &num2);sum=num1+num2;gotoxy(15,11);textcolor(MAGENTA);cprintf("Sum of %.2f and %.2f is %.2f",num1,num2,sum);diff=num1-num2;gotoxy(15,13);textcolor(MAGENTA);cprintf("Difference of %.2f and %.2f is %.2f",num1,num2,diff);pro=num1*num2;gotoxy(15,15);textcolor(MAGENTA);cprintf("Product of %.2f and %.2f is %.2f",num1,num2,pro);quo=num1/num2;gotoxy(15,17);textcolor(MAGENTA);cprintf("Quotient of %.2f and %.2f is %.2f",num1,num2,quo);getch();}

EXER 4




#include
#include
void main(){clrscr();int day;gotoxy(30,5);textcolor(YELLOW+BLINK);cprintf("._. W e L c O m e ._.");gotoxy(15,8);textcolor(GREEN);cprintf("Enter a number:");scanf("%d",&day);switch(day){case 1:gotoxy(25,10);textcolor(LIGHTRED);cprintf("Sunday");break;case 2:gotoxy(25,10);textcolor(LIGHTRED);cprintf("Monday");break;case 3:gotoxy(25,10);textcolor(LIGHTRED);cprintf("Tuesday");break;case 4:gotoxy(25,10);textcolor(LIGHTRED);cprintf("Wednesday");break;case 5:gotoxy(25,10);textcolor(LIGHTRED);cprintf("Thursday");break;case 6:gotoxy(25,10);textcolor(LIGHTRED);cprintf("Friday");break;case 7:gotoxy(25,10);textcolor(LIGHTRED);cprintf("Saturday");break;default:gotoxy(20,10);textcolor(LIGHTRED);cprintf("Oops! Sorry! That day is not available!");}getch();}

EXER 5




#include
#include
void main(){clrscr();int row,a,b,c,d,choice;gotoxy(3,2);textcolor(YELLOW);cprintf("Enter the number of rows you want to display: ");scanf("%d",&row);gotoxy(5,4);textcolor(YELLOW);cprintf("Select pattern you want to print:");gotoxy(7,6);textcolor(GREEN);cprintf("[A] Pattern 1");gotoxy(7,7);textcolor(GREEN);cprintf("[B] Pattern 2");gotoxy(7,8);textcolor(GREEN);cprintf("[C] Pattern 3");gotoxy(7,9);textcolor(GREEN);cprintf("[D] Pattern 4");gotoxy(7,11);textcolor(YELLOW);cprintf("Please make your choice: ");scanf("%s",&choice);switch(choice){case 'A':case 'a':for(a=0,d=12;a<=row;a++,d++){for(b=1,c=37;b<=a;b++,c++){gotoxy(c,d);textcolor(CYAN);cprintf("*");} }break; case 'B':case 'b': for(a=0,d=12;a<=row;a++,d++){for(b=1,c=37;b<=a;b++,c--){gotoxy(c,d);textcolor(CYAN);cprintf("*");} }break; case 'C':case 'c':for(a=row,d=13;a<=row;a--,d++){for(b=a,c=38;b>=1;b--,c++){gotoxy(c,d);textcolor(CYAN);cprintf("*");}}break;case 'D':case 'd':for(a=row,d=13;a>=1;a--,d++){for(b=a,c=38;b>=1;b--,c--){gotoxy(c,d);textcolor(CYAN);cprintf("*");}}break;default:gotoxy(5,4);textcolor(MAGENTA);cprintf("Sorry input not available!!");}getch();}

EXER 6


#include
#include
#define cp cprintf#define s scanffloat grade, average, items, sum;void main(){clrscr();average=0;sum=0;do{textcolor(YELLOW);cp("Enter grade (-1 to exit): ");s("%f", &grade);if((grade!=-1)&&(grade<=100)) { items++; sum=sum+grade; }}while(grade!=-1);average=sum/items;textcolor(GREEN);cp("Class Average: %.2f\n", average); if((average>=95)&&(average<=100)) { textcolor(GREEN);cp("Rating: A"); } else if((average>=90)&&(average<=94)) {textcolor(GREEN);cp("Rating: B"); } else if((average>=85)&&(average<=89)) { textcolor(GREEN);cp("Rating: C"); }else if((average>=80)&&(average<=84)) { textcolor(GREEN);cp("Rating: D"); } else if((average>=75)&&(average<=79)) { textcolor(GREEN);cp("Rating: E"); } else if(average<=74) { textcolor(GREEN);cp("Rating: FAILED"); }getch(); }

EXER 7











#include
#include
#define cp cprintf#define s scanffloat salary, years, bonus;void main(){clrscr();gotoxy(25,9);textcolor(YELLOW);cp("Enter Salary: P");s("%f", &salary);gotoxy(25,10);textcolor(YELLOW);cp("\nEnter Years of Service: ");s("%f", &years);bonus=0;if (years==1){bonus=salary*0.10;gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);}else if ((years<=5) && (years>=2)){bonus=salary*0.20;gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);}else if ((years<=10) && (years>=6)){bonus=salary*0.50;gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);}else if (years>=11){bonus=salary*0.75;gotoxy(25,12);textcolor(YELLOW);cp("\nBonus: P%.2f", bonus);}getch();}