Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views2 pages

Salary Calculation with Goto Statement

The document contains two C programs: one calculates an employee's total salary based on basic pay and allowances, while the other generates Pascal's Triangle for a specified number of rows. The salary program uses a switch statement to determine allowances and tax based on the basic pay input. The Pascal's Triangle program prints the triangle based on user-defined rows, formatting the output correctly.

Uploaded by

Sulochana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Salary Calculation with Goto Statement

The document contains two C programs: one calculates an employee's total salary based on basic pay and allowances, while the other generates Pascal's Triangle for a specified number of rows. The salary program uses a switch statement to determine allowances and tax based on the basic pay input. The Pascal's Triangle program prints the triangle based on user-defined rows, formatting the output correctly.

Uploaded by

Sulochana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Employee of a salary using Goto statement

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int bp1;
float bp,ta,da,tax,tot;
printf("Enter the basic pay");
scanf("%f",&bp);
bp1=bp/10000;
switch(bp1)
{
case 1:ta=bp*5/100;
da=bp*3/100;
tax=bp*2/100;
break;
case 2:ta=bp*7/100;
da=bp*5/100;
tax=bp*3/100;
break;
case 3:ta=bp*9/100;
da=bp*7/100;
tax=bp*4/100;
break;
default:ta=bp*10/100;
da=bp*9/100;
tax=bp*5/100;
break;
}
tot=bp+(ta+da)-tax;
printf("ta=%f \nda=%f \ntax=%f",ta,da,tax);
printf("\n\nTotal is %f",tot);
getch();
}

Input:
12000
Output:
Ta=600.00
Da=360.00
Tax=240.00
Total is 12720.00
Pascal’s Triangle

#include <stdio.h>
void main()
{
int row,c=1,blk,i,j;
printf("Input number of rows: ");
scanf("%d",&row);
for(i=0;i<row;i++)
{
for(blk=1;blk<=row-i;blk++)
printf(" ");
for(j=0;j<=i;j++)
{
if (j==0||i==0)
c=1;
else
c=c*(i-j+1)/j;
printf("% 4d",c);
}
printf("\n");
}
getch();
}

Output:
Input number of rows: 5
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

You might also like