Thursday, February 12, 2009

Exercise6


#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);
printf("\t\tA.) Addition \n");
printf("\t\tB.) Subtraction \n");
printf("\t\tC.) Multiplication \n");
printf("\t\tD.) Division \n");
printf(\n\t\t"Enter a Number above for the Operation: ",operation);
scanf("%sd",&operation);

switch(operation)
{
case 'A':
case 'a':

ans=num1+num2;
gotoxy(30,16);textcolor(WHITE);cprintf("The Answer is: %d",ans);
break;

case 'B':
case 'b':

ans=num1-num2;
gotoxy(30,16);textcolor(WHITE);cprintf("The Answer is: %d",ans);
break;

case 'C':
case 'c':

ans=num1*num2;
gotoxy(30,16);textcolor(WHITE);cprintf("The Answer is: %d",ans);
break;

case 'D':
case 'd':

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

}

Exercise4


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

Exercise3


#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;
if (years==1){
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



#include
#include

void main()
{ clrscr();

printf("\t\t\tA U T O B I O G R A P H Y\n\n\n\n");
printf("\t\tHajimimashite! I'm Sybel Joy S. Norcos. ");
printf("I'm 16 years of age and I live in Matina, Davao City. ");
printf("Currently, I'm studying in the University of Mindanao ");
printf("on the first year of my Computer Science course.\n");
printf("\t\tI have a kind mother whose name is Letty S. Norcos ");
printf("and i have this caring father Ramil A. Maganase, ");
printf("and I'm their only sibling. ");
printf("I knew that you'll notice something's different there, just don't mind it. >^_^< ");
printf("I'm happy that God gave me chance to live in this world, and also I'm thankful for ");
printf("the one who is reading this little piece of my life...\n\n");
printf("God Bless You Always.");


getch();
}

Exercise1


#include
#include

void main()
{
clrscr();
printf("Welcome to Programming!");

getch();
}

Exercise5






#include
#include


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

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

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