| maverickmishra (14) | |
|
what is wrong with the code? #include <iostream.h> struct Employee { int empno; char name; char dept; int salary; char category; }emp; void main() { cout<<"enter employee no"; cin>>emp.empno; cout<<"enter employee name"; cin>>emp.name; cout<<"enter the dept:"; cin>>emp.dept; cout<<"enter salary"; cin>>emp.salary; if(emp.salary>>4000) emp.category='A'; else emp.category='B'; cout<<"the employee is" ; cout<< emp.name; cout<<emp.dept; cout<<emp.salary; cout<<emp.category; } | |
|
|
|
| chipp (506) | |
if(emp.salary>>/*'>'?*/4000) | |
|
|
|
| maverickmishra (14) | |
|
thanx | |
|
|
|
| maverickmishra (14) | |
|
it says declaration syntax error #include <iostream.h> struct Employee { int empno; char name; char dept; int salary; char category; }emp; void main() { cout<<"enter employee no"; cin>>emp.empno; cout<<"enter employee name"; cin>>emp.name; cout<<"enter the dept:"; cin>>emp.dept; cout<<"enter salary"; cin>>emp.salary; if(emp.salary>4000) emp.category='A'; else emp.category='B'; cout<<"the employee is" ; cout<< emp.name; cout<<emp.dept; cout<<emp.salary; cout<<emp.category; } | |
|
|
|
| chipp (506) | |
#include <iostreamand btw, use code tag will ya... :D | |
|
|
|
| maverickmishra (14) | |
| i use pre standard C++ | |
|
|
|
| Felicia123 (158) | |||
| |||
|
|
|||
| maverickmishra (14) | |
| soory shows un expected results | |
|
|
|
| chipp (506) | |||
i guess i figured out why:
understand? (i'm a little bit lazy to write) | |||
|
|
|||
| maverickmishra (14) | |
| just explain pls a bit | |
|
|
|
| guatemala007 (11) | |||
I fixed the code. If you have any questions please fell free to ask. I made it look nice too, but you can fix that to your liking.
| |||
|
|
|||
| maverickmishra (14) | |
|
tHANX A LOT GUATEMALA007 WHATS THE USEE OF CIN.GETLINE?? | |
|
Last edited on
|
|
| maverickmishra (14) | |||
| |||
|
|
|||
| guatemala007 (11) | |
| Oh sorry didn't realize i used it, but its just so if you input spaces or blank characters into the response the computer actually includes them in the output. Normally if you entered a name followed by a space then a last name everything after the space would be ignored, but with cin.getline(); the whole input is incorporated into the char array. | |
|
|
|
| maverickmishra (14) | |
| any ways thanx @guatemala007 | |
|
|
|
| guatemala007 (11) | |
| no problem | |
|
|
|