Monday, February 16, 2009

CS121 EXER7

#include
#include
#define p printf
#define s scanf

int sum(int x, int y){
int z=x+y;
return z;
}

void sq(int n){
int sq=n*n;
p("Square of sum is %d", sq);
}

void main(){
int a,b,c;
p("Enter num1:");
s("%d", &a);
p("Enter num2:");
s("%d", &b);
c=sum(a,b);
p("Sum is %d\n", c);
sq(c);
}

CS121 EXER6

#include
#include
#define p printf
#define s scanf

float grade, average, items, sum;
void main()
{
clrscr();
average=0;
sum=0;
do
{
p("Enter grade (-1 to exit): ");
s("%f", &grade);
if((grade!=-1)&&(grade<=100))
{
items++;
sum=sum+grade;
}
}while(grade!=-1);

average=sum/items;
p("Class Average: %.2f\n", average);

if((average>=95)&&(average<=100))
{
p("Rating: A");
}
else if((average>=90)&&(average<=94))
{
p("Rating: B");
}
else if((average>=85)&&(average<=89))
{
p("Rating: C");
}
else if((average>=80)&&(average<=84))
{
p("Rating: D");
}
else if((average>=75)&&(average<=79))
{
p("Rating: E");
}
else if(average<=74)
{
p("Rating: FAILED");
}

getch();
}

CS121 EXER5

#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: ART KILAT");
getch();
}

CS121 EXER4

#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: ART KILAT");
getch();
}

CS 121 EXER 3

#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: ART KILAT");
getch();
}

CS121 EXER 2

#include
#include

main()
{
clrscr();
printf("\n\n\t\t\t\tMy Autobiography ! ! \n\n\n");
printf("I am Art E. Kilat\n17 years young,\nBorn on November 13,1991,a jolly person who always talk with sense and optimistic and idealistic\n");
printf("Im living at Buhangin , Davao City together with my family\nI graduated secondary level of education at Talomo National High School");
printf("\n\n\n\t\Thanks a Lot for viewing this!!");
printf("\n\n\n\n\t\t\t\t\t\tCreated by: Art Kilat");
getch();
}

CS 121 exer1

#include
#include
void main(){
printf("Hello world");
getch();
}