Sunday, February 15, 2009

exer6


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

exer5



#include
#include
int i,j,x,y,A,B,C,D,pattern;
void main()
{
clrscr();

printf("\n\t[A]Enter Pattern 1");
printf("\n\t[B]Enter Pattern 2");
printf("\n\t[C]Enter Pattern 3");
printf("\n\t[D]Enter Pattern 4");
printf("\n\tEnter Pattern:");
scanf("%s",&pattern);

switch(pattern)
case 'A':
for(i=1,y=8;i<=4;i++,y++) { for(j=1,x=35;j<=i;j++,x++) { gotoxy(x,y); printf("*"); }} switch(pattern) case 'B': for(i=1,y=8;i<=4;i++,y++) { for(j=1,x=35;j<=i;j++,x--) { gotoxy(x,y); printf("*"); } } switch(pattern) case 'C': for(i=4,y=8;i<=4;i--,y++) { for(j=i,x=35;j>=1;j--,x++)
{
gotoxy(x,y);
printf("*");
}
}
switch(pattern)
case 'D':
for(i=4,y=8;i>=1;i--,y++)
{
for(j=i,x=35;j>=1;j--,x--)
{
gotoxy(x,y);
printf("*");
}}
getch();
}

exer4


#include
#include
int salary, years, bonus;
void main()
{
clrscr();
printf("enter salary:");
scanf("%d", &salary);

printf("enter years of service:");
scanf("%d", &years);

switch(years)
{
case 1:
bonus= 0.10 * salary;
printf("bonus:%d", bonus);
break;

case 2:
bonus= 0.20 * salary;
printf("bonus:%d", bonus);
break;

case 3:
bonus= 0.20 * salary;
printf("bonus:%d", bonus);
break;


case 4:
bonus= 0.20 * salary;
printf("bonus:%d", bonus);
break;


case 5:
bonus= 0.20 * salary;
printf("bonus:%d", bonus);
break;

case 6:
bonus= 0.50 * salary;
printf("bonus:%d", bonus);
break;

case 7:
bonus= 0.50 * salary;
printf("bonus:%d", bonus);
break;

case 8:
bonus= 0.50 * salary;
printf("bonus:%d", bonus);
break;

case 9:
bonus= 0.50 * salary;
printf("bonus:%d", bonus);
break;

case 10:
bonus= 0.50 * salary;
printf("bonus:%d", bonus);
break;
}
if (years>=11)
bonus= 0.75 * salary;
printf("bonus:%d", bonus);

getch();
}

exer3


#include
#include


void main(){
clrscr();
int choice,a,b,n,y,sum=0,sub=0,mul=0,div=0;

printf("\n\nSelect Operation");
printf("\n\n\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("\n\nPlease enter the CAPITAL letter of the operation you choose:");
scanf("%s",&choice);
switch(choice)
{
case 'A':
printf("\n\nEnter your 1ST number pls: ");
scanf("%d",&a);
printf("Then enter the 2ND number pls: ");
scanf("%d",&b);
sum=a+b;
printf("\n\nSummation of two number is:%d",sum);
break;

case 'B':
printf("\n\nEnter your 1ST number pls: ");
scanf("%d",&a);
printf("Then enter the 2ND number pls: ");
scanf("%d",&b);
sub=a-b;
printf("\n\nDifference of two number is:%d",sub);
break;

case 'C':
printf("\n\nEnter your 1ST number pls: ");
scanf("%d",&a);
printf("Then enter the 2ND number pls: ");
scanf("%d",&b);
mul=a*b;
printf("\n\nProduction of two number is:%d",mul);
break;
case 'D':
printf("\n\nEnter your 1ST number pls: ");
scanf("%d",&a);
printf("Then enter the 2ND number pls: ");
scanf("%d",&b);
div=a/b;
printf("\n\nDivision of two number is:%d",div);
break;
}
getch(); }

exer2


#include
#include


void main(){
clrscr();
char name[50],gender[10],status[10],religion[10];
printf("Enter name:");
gets(name);

printf("Enter gender: ");
gets(gender);

printf("Enter status:");
gets(status);
printf("Enter religion:");
gets(religion);


printf("I'm %s, %s, %s, %s", name,gender,status,religion);



getch();

}

exer1


#include
#include

void main(){
clrscr();
printf("welcome to world of programming!\n");


getch();


}

Saturday, February 7, 2009