Showing posts with label Basic C program. Show all posts
Showing posts with label Basic C program. Show all posts

Saturday, December 31, 2011

Find gross salary in 'C'

Example




#include<stdio.h>
#include<conio.h>
void main()
{
float bs,hra,da,pf,gs;
clrscr();
printf("Enter basic salary:");
scanf("%f",&bs);
hra=0.125*bs;
da=0.10*bs;
pf=0.025*bs;
gs=bs+hra+da-pf;
printf("\n========GROSS SALARY OF GIVEN ALLOWANCE===============\n");
printf("\nBasic salary        =%.2f",bs);
printf("\nHouse rent allowance=%.2f",hra);
printf("\nDearness allowance  =%.2f",da);
printf("\nProvisional fund    =%.2f",pf);
printf("\n=======================================\n");
printf("\nGross salary        =%.2f",gs);
getch();
}
/*=============================================================================
OUTPUT
Enter basic salary:1000
                                                                                
========GROSS SALARY OF GIVEN ALLOWANCE===============                          
                                                                                
Basic salary        =1000.00                                                    
House rent allowance=125.00                                                     
Dearness allowance  =100.00                                                     
Provisional fund    =25.00                                                      
=======================================                                         
                                                                                
Gross salary        =1200.00   */



Find celcius from given fahrenhite in 'C'

Example



#include<stdio.h>
#include<conio.h>
void main()
{
float fahren,celc;
clrscr();
printf("Enter fahrenhite:");
scanf("%f",&fahren);
celc=(fahren - 32.0)/1.8;
printf("\n==========FAHRENHITE TO CELCIUS============\n");
printf("\nCelcius=%.2f",celc);
getch();
}
/*==============OUTPUT===============================
Fahrenhite=97
Celcius=36.7
=====================================================*/

Find month and days of given days in 'C'

Example



#include<stdio.h>
#include<conio.h>
void main()
{
int mth,day,d1;
clrscr();
printf("Enter days of your choice:");
scanf("%d",&d1);
day=d1%30;
mth=d1/30;
printf("\n========DAYS && MONTH==========\n");
printf("\nMonth =%d",mth);
printf("\nDays  =%d",day);
getch();
}
/*=====================================================================
OUTPUT
Enter days of your choice:35


========DAYS && MONTH==========


Month =1
Days  =5  */

Find area and circumference of circle in 'C'

Example



#include<stdio.h>
#include<conio.h>
void main()
{
float r;
float area,circum,p=3.14;
clrscr();
printf("Enter radius of circle:");
scanf("%f",&r);
area=(p*r*r);
circum=(2*p*r);
printf("\n========Area and circumference of circle==========\n");
printf("\nArea         =%.2f",area);
printf("\nCircumference=%.2f",circum);
getch();
}
/*==========================================================================
OUTPUT
Enter radius of circle:4
                                                                                
========Area and circumference of circle==========                              
                                                                                
Area         =50.24                                                             
Circumference=25.12 */