<?
php
$questions = [
    1 => [
        "question" => "What is the capital of France?",
        "options" => ["Paris", "London", "Berlin", "Rome"],
        "answer" => "Paris"
    ],
    2 => [
        "question" => "Which planet is known as the Red Planet?",
        "options" => ["Earth", "Mars", "Jupiter", "Venus"],
        "answer" => "Mars"
    ],
    3 => [
        "question" => "Who wrote 'Romeo and Juliet'?",
        "options" => ["William Wordsworth", "William Shakespeare", "Jane Austen",
"Mark Twain"],
        "answer" => "William Shakespeare"
    ],
    4 => [
        "question" => "What is the boiling point of water?",
        "options" => ["90°C", "100°C", "110°C", "80°C"],
        "answer" => "100°C"
    ],
    5 => [
        "question" => "Which ocean is the largest?",
        "options" => ["Indian", "Atlantic", "Arctic", "Pacific"],
        "answer" => "Pacific"
    ],
    6 => [
        "question" => "Which language has the most native speakers?",
        "options" => ["English", "Hindi", "Mandarin", "Spanish"],
        "answer" => "Mandarin"
    ],
    7 => [
        "question" => "Which is the longest river in the world?",
        "options" => ["Amazon", "Nile", "Yangtze", "Mississippi"],
        "answer" => "Nile"
    ],
    8 => [
        "question" => "Who was the first President of the United States?",
        "options" => ["Abraham Lincoln", "George Washington", "John Adams", "Thomas
Jefferson"],
        "answer" => "George Washington"
    ],
    9 => [
        "question" => "What is the largest mammal?",
        "options" => ["Elephant", "Blue Whale", "Giraffe", "Hippopotamus"],
        "answer" => "Blue Whale"
    ],
    10 => [
        "question" => "What gas do plants absorb from the atmosphere?",
        "options" => ["Oxygen", "Carbon Dioxide", "Nitrogen", "Hydrogen"],
        "answer" => "Carbon Dioxide"
    ]
];
$score = 0;
$isSubmitted = isset($_POST['submit']);
if ($isSubmitted) {
    foreach ($questions as $index => $q) {
        $selected = $_POST["q$index"] ?? "";
        if ($selected === $q['answer']) {
            $score++;
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>GK Quiz</title>
    <style>
        body {
             font-family: Arial, sans-serif;
             background: #eef2f3;
             margin: 0;
             padding: 20px;
        }
        .container {
             max-width: 800px;
             background: #fff;
             padding: 30px;
             margin: auto;
             border-radius: 10px;
             box-shadow: 0 0 15px rgba(0,0,0,0.1);
        }
        h1 {
             text-align: center;
             color: #333;
        }
        .question {
             margin-bottom: 20px;
        }
        .question h3 {
             margin-bottom: 10px;
        }
        .options label {
             display: block;
             margin-bottom: 5px;
        }
        .submit-btn {
             display: block;
             margin: 20px auto;
             padding: 12px 30px;
             background-color: #28a745;
             color: white;
             font-size: 16px;
             border: none;
             border-radius: 5px;
             cursor: pointer;
        }
        .result {
             text-align: center;
            font-size: 20px;
            color: #007bff;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>General Knowledge Quiz</h1>
        <?php if ($isSubmitted): ?>
             <div class="result">
                 You scored <?php echo $score; ?> out of <?php echo
count($questions); ?>!
             </div>
        <?php else: ?>
             <form method="post">
                 <?php foreach ($questions as $index => $q): ?>
                     <div class="question">
                         <h3><?php echo "$index. " . $q["question"]; ?></h3>
                         <div class="options">
                             <?php foreach ($q["options"] as $option): ?>
                                  <label>
                                      <input type="radio" name="q<?php echo $index; ?
>" value="<?php echo $option; ?>" required>
                                      <?php echo $option; ?>
                                  </label>
                             <?php endforeach; ?>
                         </div>
                     </div>
                 <?php endforeach; ?>
                 <button type="submit" name="submit" class="submit-btn">Submit
Answers</button>
             </form>
        <?php endif; ?>
    </div>
</body>
</html>