It is already rather simple. You could add comments to explain the logic.
Alternatively, you could move the validity check into separate function. That way it would be more obvious that the main program asks for a word (twice) and each time responds either 'Correct' or 'Incorrect'.
There is a style issue; the array 'data' has some number of elements, but the loop is hardcoded to iterate exactly two times. That is an unnecessary maintenance hazard and thus a bad example for beginners. The loop should iterate as many times as there are elements in the array.
Other bad examples are on lines 5 and 34. Nobody should learn those by default. Both can be avoided. One can learn to know and to think, or one can learn to blindly copy-paste suicidal tendencies. That naturally leads to the ethical question, which is worse: to be friendly to beginners by apparently hurting them, to be friendly to beginners by letting them hurt themselves?
#include <cctype>
#include <iostream>
#include <string>
bool is_correct(const std::string& str) {
// is incorrect (!str.empty() call is not needed here, std::cin won't accept just enter,
// but it's a good practise)
if (!str.empty() && isupper(str[0])){
for (auto i = str.begin() + 1, end = str.end(); i != end; ++i)
if (!islower(*i))
returnfalse;
}
elsereturnfalse;
// if not incorrect, return true
returntrue;
}
int main() {
std::string str;
std::cout << "Type first name: ";
std::cin >> str;
if (is_correct(str))
std::cout << "Correct!\n";
else
std::cout << "Incorrect!\n";
std::cout << "Type last name: ";
std::cin >> str;
if (is_correct(str))
std::cout << "Correct!\n";
else
std::cout << "Incorrect!\n";
std::cin.get(); // one for getting enter left in input by std::cin
std::cin.get(); // and one to pause the screen
return 0;
}