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