Monday, February 16, 2009

Exer8







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

exer 7

#include
#include

void main()
{
clrscr();

float grade,average,sum,a=0;

while(grade!=-1)
{
sum=sum+grade;
textcolor(LIGHTCYAN);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");}
if(average>=85 && average<=94){

printf("Rated B");}
if(average>=75 && average<=84){

printf("Rated C");}
if(average<=74){

printf("Failed");}
getch();

}

exer6


#include
#include
#include
void main()
{ clrscr(); int h,i,j,x,y,choice,X;
gotoxy(26,3);cprintf("P A T T E R N S");
gotoxy(25,4);textcolor(RED);cprintf("\nEnter number:");
gotoxy(41,5);textcolor(RED);scanf("%d",&h);
gotoxy(25,6);textcolor(CYAN);cprintf("\nChoose the desired pattern:");
gotoxy(25,8);cprintf("\n\t[A] for Pattern 1");
gotoxy(25,9);cprintf("\n\t[B] for Pattern 2");
gotoxy(25,10);cprintf("\n\t[C] for Pattern 3");
gotoxy(25,11);cprintf("\n\t[D] for Pattern 4");
gotoxy(25,13);textcolor(YELLOW);cprintf("\nEnter your choice from above:");
gotoxy(56,14);scanf("%s",&choice);
switch(choice)
{ case 'A':
for(i=1,y=15;i<=h;i++,y++)
{ for(j=1,x=40;j<=i;j++,x++)
{ gotoxy(x,y); printf("*"); } }
break; }
switch(choice)
{ case 'B': for(i=1,y=15;i<=h;i++,y++)
{ for(j=1,x=40;j<=i;j++,x--)
{ gotoxy(x,y); printf("*"); } }
break; }switch(choice)
{ case 'C': for(i=h,y=15;i<=h;i--,y++)
{ for(j=i,x=40;j>=1;j--,x++) {
gotoxy(x,y); printf("*"); } }
break; }switch(choice)
{ case 'D': f
or(i=h,y=15;i>=1;i--,y++)
{ for(j=i,x=40;j>=1;j--,x--)
{
gotoxy(x,y);
printf("*"); } }
break; }
gotoxy(15,20);textcolor(LIGHTBLUE);cprintf("\n\nthe program ends here.... thanks!!\n");
getch();
}

Thursday, February 12, 2009

exer 5



#include
#include

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

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

case 10:
bonus=0.50*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
break;
}
if(years>=11)
{
bonus=0.75*salary;
sum=salary+bonus;
printf("\n\tEmployee/s bonus is \"P%d",bonus);
printf("\n\nEmployee/s will receive a salary of \"P%d\"",sum);
}



getch();
}

exer 4


#include
#include
void main(){

clrscr();

int day;
gotoxy(28,5);textcolor(YELLOW);cprintf("Enter an integer:"); scanf("%d",&day); switch(day){ case 1: gotoxy(30,10);textcolor(BLUE);cprintf("Sunday"); break; case 2: gotoxy(30,10);textcolor(YELLOW);cprintf("Monday"); break; case 3: gotoxy(30,10);textcolor(GREEN);cprintf("Tuesday"); break; case 4: gotoxy(30,10);textcolor(RED);cprintf("Wednesday"); break; case 5: gotoxy(30,10);textcolor(GREEN);cprintf("Thursday"); break; case 6: gotoxy(30,10);textcolor(RED);cprintf("Friday"); break; case 7: gotoxy(30,10);textcolor(YELLOW);cprintf("Saturday"); break; default: gotoxy(20,10);textcolor(RED);cprintf("S O R R Y ! ! !Day is not available!!!!!");}
getch(); }

exer 2


#include
#include

main()
{


clrscr();
cprintf("WELCOME to THE world OF programming!!!\n");




getch();
}

Exer 3


#include
#include


void main()
{

clrscr();
int letter,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(GREEN);cprintf("\nSelect operation you like to Try!");
gotoxy(25,8);textcolor(GREEN+BLINK);cprintf("\n\tA.] ADD");
gotoxy(25,9);textcolor(GREEN);cprintf("\n\tB.] SUB");
gotoxy(25,10);textcolor(GREEN);cprintf("\n\tC.] PRODUCT");
gotoxy(25,11);textcolor(GREEN);cprintf("\n\tD.] QUIENT");
gotoxy(25,12);textcolor(GREEN);cprintf("\n\tE.] Exit");
gotoxy(25,14);textcolor(CYAN);cprintf("\nPlease choose from the following:");
scanf("%s",&letter);

switch(letter)
{
case 'A':
gotoxy(25,16);cprintf("Enter first number:");
scanf("%d",&a);
gotoxy(25,17);cprintf("Enter second number:");
scanf("%d",&b);
sum=a+b;
gotoxy(25,18);cprintf("Sum of two number is: %d",sum);

break;
}
switch(letter)
{
case 'B':
gotoxy(25,16);textcolor(YELLOW);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(YGREEN+BLINK);cprintf("Difference of two numbe is: %d",sub);

break;
}
switch(letter)
{
case 'C':
gotoxy(25,16);textcolor(VIOLET);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(ORANGE+BLINK);cprintf("Product of two numbe is: %d",mul);

break;
}
switch(letter)
{
case 'D':
gotoxy(25,16);textcolor(BLUE);cprintf("Enter number:");
scanf("%d",&a);
gotoxy(25,17);textcolor(YELLOW);cprintf("Enter another number:");
scanf("%d",&b);
div=a/b;
gotoxy(25,18);textcolor(GREEN+BLINK);cprintf("Qoutient of two numbe is: %d",div);

break;
}
switch(letter)
{
case'E':
gotoxy(25,18);textcolor(RED);cprintf("\n\nEnd of program,.. Thank you!");
}
getch();
}