Answer:
#include<iostream>
using namespace std;
//main function
int main(){
//initialization
int count_Number=1,a1,match_Numbers=0;
//loop run 10 times
do{
//print
cout<<"Enter the number: ";
//read the value enter by user
cin>>a1;
//check for match
if(a1==count_Number){
match_Numbers++;
}
count_Number++;
}while(count_Number <= 10);
//display the output
cout<<"The number of matches is: "<<match_Numbers<<endl;
return 0;
}
Step-by-step explanation:
Include the library iostream for using the input/output instruction.
create the main function and declare the variables.
take the do-while loop which has a special property, the statement in the do-while execute first and then check the condition.
In the do-while, print the message by using the cout instruction and then store the value enter by the user into the variable.
then, check the value enter by the user is match the position or not. If the condition true, then count the matches and also update the position count.
this process continues until the position count is less than or equal 10. if condition false the loop terminates and then, display the output on the screen.