Rational Number Class 8 MCQs

Maths Quiz

Class 8 Maths Quiz

const questions = [ { question: "What is the value of 6 * 7?", options: ["30", "42", "49", "54"], answer: "42", explanation: "6 * 7 = 42 because multiplication is the operation of repeated addition." }, { question: "Simplify: 8 / 2 + 3 * 4", options: ["11", "16", "18", "20"], answer: "20", explanation: "8 / 2 + 3 * 4 = 4 + 12 = 16. Division is done before addition and subtraction." }, { question: "What is the square root of 64?", options: ["4", "6", "8", "10"], answer: "8", explanation: "√64 = 8 because 8 * 8 = 64." }, { question: "If x = 5 and y = 3, what is the value of 2x - 3y?", options: ["4", "6", "8", "10"], answer: "4", explanation: "2x - 3y = 2*5 - 3*3 = 10 - 9 = 1." }, { question: "What is the next prime number after 7?", options: ["9", "11", "13", "15"], answer: "11", explanation: "The next prime number after 7 is 11 because it is divisible only by 1 and itself." }, // Add more questions here... { question: "What is the value of 3^4?", options: ["27", "64", "81", "243"], answer: "81", explanation: "3^4 = 3 * 3 * 3 * 3 = 81." }, { question: "If a square has a side of length 5 cm, what is its area?", options: ["10 cm²", "20 cm²", "25 cm²", "30 cm²"], answer: "25 cm²", explanation: "The area of a square is side * side. So, for side = 5 cm, area = 5 * 5 = 25 cm²." }, { question: "What is the value of (9 + 3) / (2 * 4)?", options: ["1", "2", "3", "4"], answer: "2", explanation: "(9 + 3) / (2 * 4) = 12 / 8 = 1.5. Division is done after addition and subtraction." }, { question: "If x = 7 and y = 2, what is the value of x² - y²?", options: ["45", "47", "49", "51"], answer: "45", explanation: "x² - y² = (7)² - (2)² = 49 - 4 = 45." }, { question: "What is the value of log₂(8)?", options: ["2", "3", "4", "5"], answer: "3", explanation: "log₂(8) = 3 because 2^3 = 8." }, // Add more questions here... ]; let currentQuestionIndex = 0; let score = 0; const questionElement = document.getElementById("question"); const optionsElement = document.getElementById("options"); const resultElement = document.getElementById("result"); const nextButton = document.getElementById("next-btn"); function displayQuestion() { const currentQuestion = questions[currentQuestionIndex]; questionElement.textContent = currentQuestion.question; optionsElement.innerHTML = ""; currentQuestion.options.forEach((option, index) => { const optionButton = document.createElement("button"); optionButton.textContent = option; optionButton.addEventListener("click", () => checkAnswer(option)); optionsElement.appendChild(optionButton); }); nextButton.disabled = true; resultElement.textContent = ""; } function checkAnswer(selectedOption) { const currentQuestion = questions[currentQuestionIndex]; if (selectedOption === currentQuestion.answer) { score++; resultElement.textContent = "Correct! " + currentQuestion.explanation; } else { resultElement.textContent = "Incorrect! " + currentQuestion.explanation; } nextButton.disabled = false; } function displayNextQuestion() { currentQuestionIndex++; if (currentQuestionIndex < questions.length) { displayQuestion(); } else { showFinalResult(); } } function showFinalResult() { questionElement.textContent = `You have completed the quiz! Your score is ${score}/${questions.length}.`; optionsElement.innerHTML = ""; nextButton.style.display = "none"; resultElement.textContent = ""; } displayQuestion(); nextButton.addEventListener("click", displayNextQuestion);