## Tuesday, July 04, 2006

### Gross salary C Program (data from Table)

This program is written on the basis of the given data in the form of a table.

#include<stdio.h>
main ()
{

char g;
int yos, qual, sal;

printf ("Enter Gender, Years of Service and Qualifications (0=G, 1=PG):");
scanf ("%c %d %d", &g, &yos, &amp;qual);

if (g=='m' && yos>=10 && qual==1)

sal=15000;
else if ((g == 'm' && yos>=10 && qual==0) || (g=='m' && yos<10 && qual==1))

sal=10000;
else if (g=='m' && yos<10 && qual==0)

sal=7000;

else if (g=='f' && yos>=10 && qual==0)

sal=12000;
else if (g=='f' && yos>=10 && qual==1)

sal=9000;
else if (g=='f' && yos<10 && qual==1)

sal = 10000;
else if (g=='f' && yos<10 && qual==0)

sal=6000;

printf ("\nSalary of Employee = Rs.%d\n", sal);

}

The file can be found at:

salman sani said...

awsum thanxxxxxxxxxxxxxxxxxxxxxxxx alot realy thankful to u :) :*

If costP rice and sellingP rice of an item is input through the keyboard, write a program to that
tells seller is at profit or loss? Further, it should ask user to enter ‘C’ if s/he wants to know how
much profit or loss seller incurred.

Anonymous said...

#include

int main()
{
int cp,sp, amt;

printf("Enter cost price: ");
scanf("%d", &cp);

printf("Enter selling price: ");
scanf("%d", &sp);

if(sp > cp)
{
amt = sp - cp;
printf("Profit = %d", amt);
}
else if(cp > sp)
{
amt = cp - sp;
printf("Loss = %d", amt);
}
else
{
printf("No Profit No Loss.");
}

return 0;
}