- 1

complie error

what is the error here #include <iostream> #include <string.h> using namespace std; struct student { int id; float gpa; string gender; }; int main() { student a[10]; for (int i=0;i<10;i++) { cout<<"enter id , gpa, gender"; std::cin>> a[i].id << a[i].gpa << a[i].gender ; } for (int i=0;i<10;i++) { for (int j=1;j<10;j++) { if (a[i].gpa<a[j].gpa) { a[i].gpa=a[j].gpa; } } } for (int i=0;i<10;i++) { cout<<a[i].gpa<<endl; } return 0; }

1st May 2017, 10:55 PM
Yossef Zidan
Yossef Zidan - avatar
3 Answers
+ 8
In your line starting as std::cin >> a[i].id , you use << instead of >> for a[i].gpa and a[i].gender.
1st May 2017, 10:59 PM
Karl T.
Karl T. - avatar
+ 8
But a thing you shouldn't do is use std:: if you use std's namespace.
1st May 2017, 11:06 PM
Karl T.
Karl T. - avatar
+ 1
can you please put it in code playground and then post the code here
1st May 2017, 10:58 PM
Edward