Here is the code
Fill the defecieny in of this code
how to import this to another file
add also how to output it into new file
#include<iostream.h>
main()
{
struct Quiz
{
char question[10];
char userAnswer[10];
char correctAnswer[10];
int scores;
};
cout<<"\n\n\t*****************QUIZ PROGRAM*****************";
cout<<"\n\n\tAnswer the following questions.";
cout<<"\n\tEnter 1 if your answer is Yes.";
cout<<"\n\tEnter 0 if your answer is NO .";
int marks=0;
struct Quiz myQuiz;
cout<<"\n\nReturn type of a function can be void?:";
cin>>myQuiz.userAnswer;
cout<<"The size of int data type is 1 byte?:";
cin>>myQuiz.userAnswer;
cout<<"In c/c++ array indexing starts from -1?:" ;
cin>>myQuiz.userAnswer;
cout<<"While loop executes at least one time?:";
cin>>myQuiz.userAnswer;
cout<<"Computer can do exactly what we tell it,1?:";
cin>>myQuiz.userAnswer;
cout<<"Using goto statement is bad progamming?:";
cin>>myQuiz.userAnswer;
cout<<"All element of array must be of different data type?:";
cin>>myQuiz.userAnswer;
cout<<"The array size must be defile with a constant number?:";
cin>>myQuiz.userAnswer;
cout<<"The continue state enforces the next iteration?:";
cin>>myQuiz.userAnswer;
cout<<"Arguments can only be passed by value to a function?:";
cin>>myQuiz.userAnswer;
char correctAnswer[10]={'1','0','0','0','1','1','0','1','1','0'};
do
{
myQuiz.scores=0;
marks++;
}while(correctAnswer== myQuiz.userAnswer);
You use cin>>myQuiz.userAnswer; but the userAnswer is an array. You should us cin>>myQuiz.userAnswer[0]; and change 0 for every answer.
The last do-while has again the same problem and also it won't check all the values of the array. When it finds the first error it will exit the loop because thecorrectAnswer[x]== myQuiz.userAnswer[x] will be false. Also every time it repeat the loop it zeros the scores again...