In: Computer Science
Note: Based on the requirement i developed a code that no of incorrect answers count is <=3
Could you plz go through this code and let me know
if u need any changes in this.Thank You
_________________
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;
//Declaring the function
char getValidChoice();
int main() {
   //Declaring constant
   const int SIZE=10;
   //Declaring variables
int correct=0,inCorrect=0;
  
//Declaring and initializing an array
   char
ans[]={'A','B','A','D','D','A','C','D','A','D'};
   char userAns[SIZE];
  
   //This loop will continue until the user incorrect
answers count is <=3
   while(true)
   {
   for(int i=0;i<SIZE;i++)
   {
      
cout<<"Question#"<<(i+1)<<":"<<endl;
       userAns[i]=getValidChoice();
   }
  
   for(int i=0;i<SIZE;i++)
   {
   if(userAns[i]==ans[i])  
   {
       correct++;
   }
   else
   {
       inCorrect++;
   }
   }
  
   if(inCorrect<=3)
   {
       cout<<"** Quiz is over
**"<<endl;
       cout<<"No of Correct
:"<<correct<<endl;
       cout<<"No of Incorrect
:"<<inCorrect<<endl;
       break;
   }
   else
   {
   system ("CLS");
   }      
   }
  
  
   return 0;
}
char getValidChoice()
{
   char choice;
   while(true)
   {
       cout<<"Enter Answer :";
       cin>>choice;
       choice=toupper(choice);
       if(choice!='A' &&
choice!='B' && choice!='C' && choice!='D')
       {
           cout<<"**
Inavlid Choice.Must be either A , B , C or D **"<<endl;
       }
       else
       break;
   }
   return choice;
}
______________________________
Output:

____________________Thank Youi
C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\Quiz 10Questions.exe Question#1: Enter Answer :A Question#2: Enter Answer :F ** Inavlid Choice. Must be either A, B, C or D ** Enter Answer :B Question#3: Enter Answer :A Question#4: Enter Answer :D Question#5: Enter Answer :D Question#6: Enter Answer :A Question#7: Enter Answer :C Question#8: Enter Answer :D Question#9: Enter Answer :D Question#10: Enter Answer :C ** Quiz is over ** No of Correct :8 No of Incorrect :2 Process exited after 18.46 seconds with return value o Press any key to continue ....