fork download
  1. #include<iostream>
  2. #include <vector>
  3.  
  4.  
  5.  
  6. struct employee
  7. {
  8. char name[20];
  9. float salary;
  10. int birthday;
  11. char sex [10];
  12.  
  13. };
  14. void main()
  15. {
  16.  
  17. employee emp[100];
  18.  
  19. {
  20. int n;
  21.  
  22. cout << "A program for collecting employee information";
  23. cout << endl;
  24. cout << "And displaying the collected information";
  25. cout << endl << endl;
  26. cout << "How many employees:";
  27. cin >> n;
  28. cout << endl;
  29.  
  30.  
  31. cout << "Enter the following information:"<<endl;
  32. cout << endl;
  33.  
  34. for (int i=0; i<n; i++){
  35. cout << "Enter information for employee no: " << i;
  36. cout << endl;
  37.  
  38.  
  39. cout<<"Enter the Employee name :" ;cin>>emp[i].name;
  40. cout<<"Enter the salary :";cin>>emp[i].salary;
  41. cout<<"Enter the birthday :";cin>>emp[i].birthday ;
  42. cout<<"Enter the sex :";cin>>emp[i].sex;
  43. cout<<endl;
  44. }
  45.  
  46.  
  47. void bubb(employee emp,int n); //bubble sort
  48. {
  49. employee temp;
  50. for(int j=0;j<n;j++)
  51. {
  52. if(emp[j].salary<emp[j+1].salary)
  53. {
  54. for(int i=j;i<n-1;i++)
  55. {
  56. temp=emp[i];
  57. emp[i]=emp[i+1];
  58. emp[i+1]=temp;
  59. }
  60. }
  61. }
  62.  
  63.  
  64. cout << "Employee entered information:"<< endl;
  65. cout << "============================" << endl;
  66. cout << "Name salary birthday Sex " << endl;
  67. for( i=0;i<n;i++)
  68. {
  69. cout << emp[i].name << "\t";
  70. cout << emp[i].salary << "\t";
  71. cout << emp[i].birthday; cout << "\t";
  72. cout << emp[i].sex ;
  73. cout << endl;
  74.  
  75. }
  76.  
  77.  
  78. int highest_salary=0;
  79. int total_salary=0;
  80. for ( i = 0; i < n; i++) {
  81. if (emp[i].salary > highest_salary)
  82. highest_salary = emp[i].salary;
  83.  
  84. total_salary += emp[i].salary;
  85. }
  86. cout<<endl;
  87. cout << "Total Salary: " << total_salary <<endl;
  88. cout << "============"<<endl;
  89. cout << "Highest Salary: " << highest_salary << endl;
  90. cout << "=============="<<endl;
  91.  
  92.  
  93.  
  94. void main(); //calc tax
  95.  
  96. float tax=0;
  97. float salary=0;
  98.  
  99. if (emp[i].salary<=1999)
  100. {
  101. tax=(emp[i].salary*5)/100;
  102. }
  103.  
  104. else if (emp[i].salary<=2999)
  105. {
  106. tax=(emp[i].salary*7.5)/100;
  107.  
  108. }
  109.  
  110. else if (emp[i].salary<=3999)
  111. {
  112. tax=(emp[i].salary*10)/100;
  113. }
  114.  
  115.  
  116. else if (emp[i].salary>4000)
  117. {
  118.  
  119. tax=(emp[i].salary*15)/100;
  120. }
  121.  
  122.  
  123. salary=emp[i].salary-tax;
  124.  
  125.  
  126.  
  127. cout<<"Salary after tax :"<<" Employee Name : "<<endl;
  128. cout<<"================ " <<" ============="<<endl;
  129. for( i=0;i<n;i++)
  130. cout<< salary<<" " << emp[i].name<<endl;
  131. }
  132.  
  133. }
  134. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:14:11: error: ‘::main’ must return ‘int’
prog.cpp: In function ‘int main()’:
prog.cpp:22:2: error: ‘cout’ was not declared in this scope
prog.cpp:22:2: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.7/iostream:62:18: note:   ‘std::cout’
prog.cpp:23:10: error: ‘endl’ was not declared in this scope
prog.cpp:23:10: note: suggested alternative:
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/4.7/ostream:562:5: note:   ‘std::endl’
prog.cpp:27:2: error: ‘cin’ was not declared in this scope
prog.cpp:27:2: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.7/iostream:61:18: note:   ‘std::cin’
prog.cpp:67:6: error: ‘i’ was not declared in this scope
prog.cpp:80:7: error: ‘i’ was not declared in this scope
prog.cpp:94:11: error: ‘::main’ must return ‘int’
prog.cpp:99:9: error: ‘i’ was not declared in this scope
prog.cpp:123:12: error: ‘i’ was not declared in this scope
stdout
Standard output is empty