Need urgent Help.pls

Something wrong with output
getdata() works beautifully
while putdata() is malfunctioning
here's the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class teacher
{
int code,salary;
char subject[20],name[25],designation[15];
public:
void getdata()
{
cout<<"\nEnter the code:";
cin>>code;
cout<<"Enter name:";
gets(name);
cout<<"Enter subject:";
gets(subject);
cout<<"Enter Designation:";
gets(designation);
cout<<"Enter Salary:";
cin>>salary;
}
void putdata()
{
cout<<"\n\nCode:"<<code;
cout<<"\nName:";
puts(name);
cout<<"Subject:";
puts(subject);
cout<<"Designation:";
puts(designation);
cout<<"Salary Rs.:"<<salary;
}
float getsalary()
{
return salary;
}
};
void sort(teacher T[10],int n)
{
int i,j;
teacher t;
for(i=0;i<n;i++)
{
for(j=0;j<(n-1);j++)
{
if(T[j].getsalary()>T[j+1].getsalary())
{
t=T[j];
T[j]=T[j+1];
T[j+1]=t;
}
}
}
}
void main()
{
clrscr();
teacher T[10];
int n,i;
cout<<"Enter number of teachers:";
cin>>n;
for(i=0;i<n;i++)
{
T[i].getdata();
}
sort(T,n);
clrscr();
for(i=0;i<n;i++)
{
T[i].putdata();
}
getch();
}


2moro I hav 2 submit this as project..so pls help fast..
Something wrong with output
getdata() works beautifully
while putdata() is malfunctioning
here's the code:

Please be more specific than putdata() is malfunctioning.


2moro I hav 2 submit this as project..so pls help fast..

Being more specific would help. Also using some sort of indentation scheme in your code could only make it far more readable.

Why are you using C input and output functions alongside C++ input and output streams?
here's what's wrong with putdata():
salary output shows negative and wrong values



I have no idea what you asked me from the last line.
hello? someone!!!!!
Topic archived. No new replies allowed.