Will you please tell me whats wrong with my codes here, i coudn\'t open it. #inc
ID: 3536540 • Letter: W
Question
Will you please tell me whats wrong with my codes here, i coudn't open it.
#include"stdafx.h"
#include
<iostream>
#include
<conio.h>
#include
<stdio.h>
#include
<string.h>
struct
emp
{
int empcode;
char empname[20];
char desig[20];
float bsal,hra,da,netsal;
void calculate();
public:emp()
{
empcode=0;
bsal=0.0;
hra=0.0;
da=0.0;
netsal=0.0;
strcpy (empname,
"No middle name");
strcpy (desig,
"No middle name");
}
void
input();
void
output();
}ob[10];
void emp::calculate()
{
netsal=bsal+hra+da;
}
void emp::input()
{
cout <<
" Enter the employee code:" ;
cin >>empcode;
cout<<
" Enter the employee name:";
gets(empname);
cout<<
" Enter designation:";
gets(desig);
cout<<
" Enter the basic salary:";
cin>>bsal;
cout<<
" Enter HRA:";
cin>>hra;
cout<<
" Enter DA:";
cin>>da;
calculate();
}
void emp::output()
{
cout<<empcode;
cout<<empname;
cout<<desig;
cout<<netsal;
}
void
main()
{
clrscr();
int i,n;
cout<<
" Enter the number of employees:";
cin>> n;
for(i=0;i<n;i++)
{
ob[i].input();
}
cout<<
" Code Name Salary ";
for(i=0;i<n;i++)
{
ob[i].output();
cout <<endl;
}
getch();
}
%u3000
//SOME CODES GOES HERE?
%u3000
Enter the employee code:100
Enter the employee name:Penguino
Enter designation:ceo
Enter the basic salary:25000
Enter HRA:1500
Enter DA:1200
Enter the employee code:101
Enter the employee name:Darth
Enter designation:manager
Enter the basic salary:15000
Enter HRA:1600
Enter DA:1000
Enter the employee code:102
Enter the employee name:Ryedell
Enter designation:wire engineer
Enter the basic salary:5000
Enter HRA:1000
Enter DA:500
%u3000
Code Name Desig Salary
100 penguino ceo 27700
101 Darth manager 17600
102 Ryedell workerbee 6500
Explanation / Answer
stdafx.h is a file, generated by Microsoft Visual Studio IDE wizards, that describes both standard system and project specific include files that are used frequently but hardly ever change.
Compatible compilers (for example, Visual C++ 6.0 and newer) will precompile this file to reduce overall compile times. Visual C++ will not compile anything before the #include "stdafx.h" in the source file, unless the compile option /Yu'stdafx.h' is unchecked (by default); it assumes all code in the source up to and including that line is already compiled.
The AFX in stdafx.h stands for Application Framework eXtensions. AFX was the original abbreviation for the Microsoft Foundation Classes (MFC). While the name stdafx.h is used by default, projects may specify an alternative name and handle all includes files containing in project file.
the code work perfectly without usinf stdafx.h header file
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
struct
emp
{
int empcode;
char empname[20];
char desig[20];
float bsal,hra,da,netsal;
void calculate();
public:emp()
{
empcode=0;
bsal=0.0;
hra=0.0;
da=0.0;
netsal=0.0;
strcpy (empname,
"No middle name");
strcpy (desig,
"No middle name");
}
void
input();
void
output();
}ob[10];
void emp::calculate()
{
netsal=bsal+hra+da;
}
void emp::input()
{
cout <<
" Enter the employee code:" ;
cin >>empcode;
cout<<
" Enter the employee name:";
gets(empname);
cout<<
" Enter designation:";
gets(desig);
cout<<
" Enter the basic salary:";
cin>>bsal;
cout<<
" Enter HRA:";
cin>>hra;
cout<<
" Enter DA:";
cin>>da;
calculate();
}
void emp::output()
{
cout<<empcode;
cout<<empname;
cout<<desig;
cout<<netsal;
}
void
main()
{
clrscr();
int i,n;
cout<<
" Enter the number of employees:";
cin>> n;
for(i=0;i<n;i++)
{
ob[i].input();
}
cout<<
" Code Name Salary ";
for(i=0;i<n;i++)
{
ob[i].output();
cout <<endl;
}
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.