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, &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:
Download File
Gender | Years of Service | Qualifications | Salary |
Male | >=10 | Post-Graduate | 15000 |
>=10 | Graduate | 10000 | |
<10 | Post-Graduate | 10000 | |
<10 | Graduate | 7000 | |
Female | >=10 | Post-Graduate | 12000 |
>=10 | Graduate | 9000 | |
<10 | Post-Graduate | 10000 | |
<10 | Graduate | 6000 |
#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, &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:
Download File
Comments
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.
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;
}