my teacher told me my "name-in" string should loop from first name-in to las name-in i just need to ask how to make sure that the number of students names matches the number of students i originally entered.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int students;
string name-in;
int first;
int last;
cout << "Please enter the number of students in your class" << endl;
cin >> students;
if((students>=1) && (students<=25)){
cout << "please enter the names of your students." << endl;
cin >> name-in;
first = name-in;
last = name-in;
while(students<=2)
if (name-in < first)
first = name-in;
if (name-in > last)
last = name-in
student++
}
else{
cout << "please press any key and enter a new number." << endl;
}
system("pause");
return 0;
}
# include <iostream>
# include <vector>
# include <string>
# include <cstdlib>
usingnamespace std;
int main()
{
int students;
cout << "Please enter the number of students in your class" << endl;
cin >> students;
vector<string> name_in;
string name = "default";
if((students>=1) && (students<=25))
{
cin.ignore();
int i=1;
while(name.size()!=0)
{
cout << "Enter the name of the student nbr " << i++ << " -> ";
getline(cin,name);
if(name.size()!=0)
name_in.push_back(name);
}
}else cout << "please press any key and enter a new number." << endl;
if(name_in.size()==(size_t)students)
cout << "The number is even" << endl;
else cout << "It is not!" << endl;
system("pause");
return 0;
}
this is great thank you but the only thing i'm missing is trying to limit students to the original number entered in the program. i tried setting i=students.