Answer:
The following code is written from C++ Programming Language.
num = 0; //integer type variable is initialized
string pre = "xxxxx", current, next; // three string type variable is initialized
cin >> current; //get input from user
while (current != "xxxxx") { //set while loop
cin >> next; //get input from the user
if (pre != current && current != next) { //set if statement
num++;
}
//swap the values.
pre = current;
current = next;
}
Step-by-step explanation:
Here, we initialized an integer type variable "num" to 0.
Then, we initialized the three string type variable "pre" to "xxxxx", "current", "next".
Then, we get input from the user in "current" and then, we set the while loop then, we get input from the user in "next".
Then, we set the if statement and increment the num variable by 1.
After all, we swap the variables.