I'm trying to make a small program that grades a test. When the program runs, it only asks you to input the first answer, then skips all the rest. If the answer is correct, it's supposed to add 2 to the score. If the answer is wrong, it subtracts one from the score. If the question was skipped, it neither hurts nor helps you.
For the purposes of this program, all of the correct answers are to be "t" for True.
Only the first part should be relevant, but I added the whole code to be safe.
bool answer[21]
for (int i = 1 ; i <= 20 ; i++)
cout << "Insert answer " << i <<endl;
cin >> answer[i]
Iam a beginner myself, but your code looks really "beginnerlike", even for me ^^
There are some nice tutorials on this site, maybe you want to look into them? http://www.cplusplus.com/doc/tutorial/
i would try something like this. Please i only started programing 3 weeks ago while doing chemo so there is a part i was have problems with perhaps someone can help you with that part.
//Student score to help Kyuunbicalvery V.5 Date:8/26/15 E.Stephan
//Enter student answers to get score
#include <iostream>
#include <vector>
using namespace std;
int main()
{
//Defining you var for program
string name = "";
string ID = "";
vector <char> answer;
char userInput =' ';
double score = 0;
//Getting student info could also be put in a vector that way you can do the whole class in one program
cout << "Insert student's name. \n" ;
cin >> name;
cout << "Insert student's ID number. \n";
cin >> ID;
//directions on using the program
cout << "Insert the student's first answer. t for True, f for False. ";
// This for loop will get the test results and store them in a vector call answer
for (int i=0; i<= 19; i++)
{
cout << "Please insert answer for question " << i << "\n";
cin >> userInput;
answer.push_back(userInput);
}
//someone will have to help you here as i am just 3 weeks into this and just learning vectors