Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ONE-DIMENSIONAL ARRAY
- Porquillo, Aljan A.
- LABORATORY EXERCISE 1 - 02
- ONE DIMENTIONAL ARRAY
- */
- #include <iostream>
- using namespace std;
- int scores = 0;
- char input;
- char answers[] = {
- 'D', 'C', 'D', 'D', 'A',
- 'B', 'C', 'A', 'B', 'B',
- 'C', 'D', 'A', 'B', 'C',
- 'D', 'D', 'A', 'B', 'A',
- 'A', 'B', 'D', 'A', 'C'
- };
- int main(){
- for(int i = 0; sizeof(answers) > i; i++){
- system("cls");
- cout << "Question " << i+1 << endl;
- cout << "Answer: ";
- cin >> input;
- if(input == answers[i]){
- scores++;
- }
- cin.ignore();
- }
- system("cls");
- cout << "Total scores " << scores << " out of " << sizeof(answers) << endl;
- if(scores >=15){
- cout << "Congrats! you have passed" << endl;
- }
- else{
- cout << "Sorry! you failed" << endl;
- }
- }
- /* PSEUDO CODE
- set variable score to 0
- set variable char to input
- set predefined array with answers
- loop size of answers then increment
- display "Question up to 1 to 25"
- display "Answer"
- then user input answer to allocate in set variable "input"
- condition if true inputed answers will correct in the save array
- increment
- ignore to be input again
- system clear
- display total scores out of 25 numbers
- if score is greater or equal to 15
- display Passed!
- else
- display Failed!
- end program
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement