I don't see any use in using the structure
Hi
One simple question. In the simple programs I have done so far about the use of the structure I have failed to see any benefit of using the structure syntax. Could you please tell me what is the benefit of using the structure syntax in the follow code? Thanks.
Code:
// number of employees having salary greater than $12,000
#include <iostream>
#include <cstdlib>
using namespace std;
////////////////////////////////////////////////////
struct employee
{ int empno; float sal; };
////////////////////////////////////////////////////
int main()
{
int empsalgrt12 = 0;
int numofemp;
employee record;
cout << "how many employees are there?: ";
cin >> numofemp;
cout << endl;
for (int i=1; i<=numofemp; i++)
{
cout << "enter employ no.: ";
cin >> record.empno;
cout << "enter salary: ";
cin >> record.sal;
cout << endl;
if ( record.sal > 12000 )
{
empsalgrt12++;
}
}
cout << "number of employees with salary greater than $12,000: " << empsalgrt12 << endl;
return 0;
system ("pause");
}