May 26, 2007

C++ program to demonstrate Structure

// This program will ask user to input Basic salary and program will
// calculate da 10%, hra 10%, pf 15%, fpf 20% and netamount according to
// this formula : net=bs +da+hra-pf-fpf
#include<iostream.h>
#include<conio.h>

struct student
{
int basicSalary;
float da,hra,pf,fpf,net;

void cal()
{
da = .1*basicSalary;
hra = .1*basicSalary;
pf = .15*basicSalary;
fpf = .2*basicSalary;
net= basicSalary*(1-.15);
}
};
main()
{
clrscr();

student s[5];

for(int i=0;i<=4;i++)
{

cout << "enter basic salary";
cin >> s[i].basicSalary;
s[i].cal();
cout<<"net "<<s[i].net<<endl;
}
getch();
}

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us