Urgent programming project.

Hello, i am doing a program for c++. i am making a simple testing program with 20 questions with 4 answers for each question, and when the wrong answer the program has to output the correct answer.At the end of the program it has to count the number of correct answers and give the percentage. ive started writing it but i keep getting errors. pleas can you look at it , give me tips, and tell me whats worng. please and thanks.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//REPS2.cpp
//Morgan Huguelet

#include <iostream.h>

main()
{
 int answer;
 int i;         // counter used by for loop
float A,B,C,D;
 char correct;
 char ERROR;

 cout << "Welcome, this is a test about Spanish.\n";
 cout << " \n";
 cout << "and I for independents or other parties.\n";
 
 for (i = 1; i <= correct; i++)
  {
   do
    { // first question
     cout << "Question 1: What is the word for 'last year' " << i << ;
     cout << " A = Pasado Ano"<<'\n';
     cout << " B = Ayer ano"<<'\n';
     cout << " C = ayer noche"<<'\n';
     cout << " D = rapido noche"<<'\n';
     cin  >> answer;
     
     switch(answer)
      {
       case 'A':
            cout<<"Good job!"<<'/n';
             break;
       case 'B':
            cout<<"Incorrect sorry the correct answer was A"<<'/n';
             break;
       case 'C':
            cout<<"Incorrect sorry the correct answer was A"<<'/n';
            break;
       case 'D':
            cout<<"Incorrect sorry the correct answer was A"<<'/n';
            break;
       default:
        cout << "Invalid entry. Enter A, B , C, or D.\n";
        correct = ERROR;
        break;
      } // end of switch structure
      do
    { // 2nd question
     cout << "Question 2:How do you say 'I am going to Meijer?' " << i << ;
     cout << " A = Vamos soy Meijer. "<<'\n';
     cout << " B = Ir Meijer."<<'\n';
     cout << " C = Voy a Meijer."<<'\n';
     cout << " D = Ir a Meijer."<<'\n';
     cin  >> answer;
     
     switch(answer)
      {
       case 'A':
            cout<<"Incorrect sorry the correct answer was c"<<'/n';
             break;
       case 'B':
            cout<<"Incorrect sorry the correct answer was C"<<'/n';
             break;
       case 'C':
            cout<<"Good job!"<<'/n';
            break;
       case 'D':
            cout<<"Incorrect sorry the correct answer was C"<<'/n';
            break;
       default:
        cout << "Invalid entry. Enter A, B , C, or D.\n";
        party = ERROR;
        break;
      } // end of switch structure
    } while (correct == ERROR); // loop again if invalid choice is made
}
 cout << "You got " <<  << " out of 20."
 }
      
 system("pause");
 return 0;
}
you have 2 do-while loops but only one is finished with while!
each do must have an while as well!

one more tip:

do not include <iostream.h> reather include <iostream>do not use system("pause") but use cin.ignore();


your code:
1
2
3
char ERROR;
//...
 while (correct == ERROR); 


do you realise that all number except 0 are threated as true?
that is:

1
2
3
4
5
6
7
8
9
-4 is true
-445 is true
4 is true
109 is true
-98 is true
-54.45 is true
56 is true

ONLY 0 is false!
thanks,. so i completed the first loop. and my compiler wont work without the .h in the #include<iostream.h> and i get more errors wit hthe cin.ignor();
and what do you mean with the last part? i understand only 0 is false but i dont get what your reffering to. sorry.
and now im getting a ton of errors.
expected primary-expression before ';' token
expected `;' before '}' token
At global scope:
by last part I mean this:
 
for (i = 1; i <= correct; i++)

correct is not initialized so it can be false at program startup

correct = ERROR;

again neather of them is initialized.

initialize variable before u use it.

my compiler wont work without the .h in the #include<iostream.h>

that's strange.

i get more errors wit hthe cin.ignor();


it's not cin.ignor();

it is cin.ignore();

and now im getting a ton of errors.
expected primary-expression before ';' token
expected `;' before '}' token
At global scope:


not to hestitate you but you need to learn how to debug and understand errors.

now I'm litle tierd, it's 5:00h and I have to into bet.
hope someone will explain you until tomorow :)

cheers Morgan!
THanks codekiddy. :)
Topic archived. No new replies allowed.