respected sir,
last time u said that send me ur program and i will identify ur mistake. sir here is two programs both showing the same header mistake. plzz identify my mistake. regards
# include main() { cout<< "How are u? welcome to my program"; }
and
#include main() { int age1, age2; age1=25; age2=15; if(age1>age2) cout<<"person 1 is older than 2nd one"; }
Posts: 95
Threads: 19
Joined: Oct 2010
Dear student!
Correct program 1 is
#include<iostream.h>
main()
{
cout<< "How are u? welcome to my program";
system("pause");
}
Correct program 2 is
#include<iostream.h>
main()
{
int age1, age2;
age1=25;
age2=15;
if(age1>age2)
{
cout<<"person 1 is older than 2nd one";
system("pause");
}
}
Try these programs and compare them with posted programs to check your mistakes.
Posts: 95
Threads: 19
Joined: Oct 2010
Dear Student,
The corrected modified code of your program is given below. There were few errors in your code. Please compare this code with your previous code and point out your mistakes which you had done.
Code:
#include<iostream.h>
#include<conio.h>
void getsalary(double sal[][2],int);
void displaysalary (double sal[][2],int);
void calcsalary(double sal[][2],int);
void findunluckies(double sal[][2],int lucky[],int);
main()
{
int numemps;
const int arraysize=100;
double sal[arraysize][2];
int lucky[arraysize]={0};
cout<<"PLEASE ENTER THE NUMBER OF EMPLOYEES:\t";
cin>>numemps;
getsalary(sal,numemps);
cout<<endl;
cout<<"DISPLAY THE GROSS SALARY:\t\t";
cout<<endl;
displaysalary(sal,numemps);
cout<<"THE NET SALARY IS HERE:";
cout<<endl;
calcsalary(sal, numemps);
cout<<"THE UNLUCKY EMPLOYEES ARE HERE:";
cout<<endl;
findunluckies(sal,lucky,numemps);
system("pause");
}
void getsalary(double sal[][2],int numemps)
{
int i;
for (i=0;i<numemps;i++)
{
cout<<"PLEASE ENTER THE SALARY OF EACH EMPLOYEE "<<i+1;
cout<<":\t";
cin>>sal[i][0];
}
cout<<endl;
}
void displaysalary (double sal[][2],int numemps)
{
int i;
for (i=0;i<numemps;i++)
{
cout<<sal[i][0];
cout<<endl;
}
cout<<endl;
}
void calcsalary(double sal[][2],int numemps)
{
double tax;
int i;
int j;
for (i=0;i<numemps;i++)
{
if (sal[i][0]<=10000)
{
tax=0;
cout<<sal[i][0];
cout<<endl;
}
else if (sal[i][0]>10000)
{
tax=0.05*sal[i][0];
sal[i][1]=sal[i][0]-tax;
cout<<sal[i][1];
cout<<endl;
}
else if (sal[i][0]>15000)
{
tax=0.15*sal[i][0];
sal[i][1]=sal[i][0]-tax;
cout<<sal[i][1];
cout<<endl;
}
}
cout<<endl;
}
void findunluckies(double sal[][2],int lucky[],int numemps)
{
int i;
for (i=0;i<=numemps;i++)
{
if (sal[i][0]>sal[i][1])
{
lucky[i]=1;
break;
}
}
cout<<endl;
for (i=0;i<=numemps;i++)
{
if ( lucky[i] ==1)
{
cout<<lucky[i];
cout<<endl;
}
}
cout<<endl;
}