if any student is named Jackson, help please
Hi :)
The code below is incomplete but still you can run it. There is some problem with it. When I have entered student #1's data it cycles through the loop automatically without asking for any data input. Please help me to solve the problem. Thanks.
Code:
// if_any_student_named_jackson_heights.cpp
// check if any student is named Jackson Heights
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <iomanip>
using namespace std;
struct Student {char name[16]; int rollno; string sex; int age; float marks;};
const int N = 5;
Student stud[N];
int main()
{
int i;
cout << "enter the students' details below\n\n";
for (i=0; i<N; i++)
{
cout << "enter student #" << (i+1) << "\'s name: ";
cin.get(stud[i].name, 16);
cout << "enter roll no.: ";
cin >> stud[i].rollno;
cout << "enter sex: ";
cin >> stud[i].sex;
cout << "enter age: ";
cin >> stud[i].age;
cout << "enter marks: ";
cin >> stud[i].marks;
}
system("pause");
return 0;
}