C 语言问答游戏2024年8月28日 | 阅读 45 分钟 在本文中,您将学习一个使用 C 语言构建的测验游戏项目。这个测验游戏旨在测试您的常识。 程序中涉及的方法或函数
让我们通过它们各自的代码和用途来理解上面讨论的所有方法或函数。 1. main()对上述方法或函数的解释“main()”方法首先被声明,其中所有其他函数都根据用户输入而被访问。此方法声明的方式是,如果用户想开始游戏,他应该通知系统他想开始游戏。同样,如果他想查看高分,他必须告知系统他想知道高分。 整个过程通过 switch case 语句完成。如果用户输入 1,系统将明白用户想开始测验游戏。如果用户输入 2,系统将明白用户想访问所有高分。如果用户输入 3,系统将明白用户想寻求帮助,然后显示玩测验所需的所有说明。 2. high_score()对上述方法或函数的解释“high_score()”方法首先被声明,其中可以访问之前玩过测验游戏的用户的高分,并在调用此方法后显示所有分数。最初,会创建一个文件,其中存储了之前玩家的所有分数,以便用户可以看到所有这些分数。如果文件为空,用户将收到一条消息,提示没有之前的游戏记录。如果文件不为空并且包含一些已存储的数据,则表示有一些人之前玩过游戏。 因此,所有曾经是高分的得分都将被显示。在屏幕上显示分数后,将询问用户是否仍想继续游戏或退出。如果用户希望继续,他/她必须输入 1。否则,他/她必须输入 0 以退出游戏界面。这个过程是通过条件语句,“if else 语句”来完成的。通过这种方式,“high_score()”函数工作并找出之前的高分。 3. help()对上述方法或函数的解释“help()”方法首先被声明,其中清楚地解释了应该遵循的规则和需要的说明。当用户想了解游戏及其说明时,用户将访问此方法。通过这种方式,该方法被使用。一旦用户访问该方法,该方法就会显示游戏的所有规则和说明。 游戏说明包括游戏中将要问的总问题数、正确答案的得分数、每个错误答案扣除的分数等。如果用户确实想玩游戏,这些信息对他/她来说就足够了。如果用户想退出游戏,他可以在此方法中直接输入 0。如果用户想开始玩游戏,他应该输入 1。 4. start()可以通过合并上面讨论的所有方法来构建完整的程序,然后形成一个更简单的程序,以便在 C 编程语言中构建一个测验游戏。 演示测验游戏构建的程序上述程序的输出 Please enter 1 to start the game Please enter 2 to the high scores Please enter 3 to seek help Please enter 0 to exit Enter your choice: 3 Instructions that are supposed to be followed while playing this game: Quiz Game in C ...................................................... You are supposed to answer 20 questions in this game !! There will be 4 options given for each questions which are marked with a serial number starting from 1 to 4. For each correct answer, you will be awarded with 5 points !! As soon as you answer a question, you will be directed to the next question without any pause. If your answer is wrong, no marks will be deducted from your score !! !! Wish you all the best !! Do you still wish to continue playing ? If yes, then press 1. Else, press 0 : 1 Enter your Full name: Nikhitha You have entered the "Quiz game in C" Welcome to the game " Nikhitha " The quiz game will be started now. Get ready to answer the questions !! ALL THE BEST !! Question 1: In the following given characteristics, which one is not related to the federal government ? 1. Flexible Constitution 2. Written Constitution 3. Independent Judiciary 4. Supremacy of the Constitution Please enter your answer: 1 Your answer is absolutely correct You score 5 points !! Question 2: In the following given members, who was the first person belonging to India entered into the space ? 1. Ravish Malhotra 2. Vikram Ambalal 3. Rakesh Sharma 4. Nagapathi Bhat Please enter your answer: 3 Your answer is absolutely correct You score 5 points !! Question 3: Who was the first women to reach the summits of all seven highest mountain peaks on every continent ? 1. Junko Tabei 2. Bachendri Pal 3. Premlata Agarwal 4. Santosh yadav Please enter your answer: 1 Your answer is absolutely correct You score 5 points !! Question 4: Who was the first person to be the Indian Prime Minister ? 1. Prathiba Patel 2. Jawaharlal Nehru 3. Rabindranath Tagore 4. Lal Bahadur Shastri Please enter your answer: 2 Your answer is absolutely correct You score 5 points !! Question 5: How many bones does an adult human skeleton have ? 1. 207 bones 2. 205 bones 3. 206 bones 4. 210 bones Please enter your answer: 3 Your answer is absolutely correct You score 5 points !! Question 6: Which blood group out of the following is known to be universal acceptor ? 1. AB + 2. AB - 3. O + 4. O - Please enter your answer: 2 The answer that you have entered is wrong. The correct answer for the above question is option no. 1. AB + Question 7: What is Vitamin K also known as ? 1. Riboflavin 2. Thiamine 3. Ascorbic acid 4. Pentamine Please enter your answer: 1 The answer that you have entered is wrong. The correct answer for the above question is option no. 3. Ascorbic acid Question 8: Out of the following membranes, which membrane is mostly present in both Spinal cord and Brain ? 1. Meninges 2. Arachnoids 3. Plasma Membrane 4. Pleural membrane Please enter your answer: 1 Your answer is absolutely correct You score 5 points !! Question 9: Which person among the following people have contributed their time to represent the first budget of India after its Independence ? 1. Manmohan Singh 2. Jawaharlal Nehru 3. Pranav Mukherjee 4. R. K. Shanmukham Chetty Please enter your answer: 2 The answer that you have entered is wrong. The correct answer for the above question is option no. 4. R. K. Shanmukham Chetty Question 10: Which position out of the following has a right to select and appoint a Prime Minister ? 1. President 2. Chief Justice of India 3. Governor 4. Vice President Please enter your answer: 1 Your answer is absolutely correct You score 5 points !! Question 11: The federal union country India consists of how many union territories ? 1. 6 2. 7 3. 8 4. 9 Please enter your answer: 3 Your answer is absolutely correct You score 5 points !! Question 12: Out of the following people, which person belonging to India was the first one to win the Booker Price ? 1. Arundhati Roy 2. Aravind Adiga 3. Nirad C. Chaudhuri 4. Dhan Gopal Mukerji Please enter your answer: 1 Your answer is absolutely correct You score 5 points !! Question 13: Out of the following languages, which language is the mainly spoken language in the state Meghalaya ? 1. Khulu 2. Thayaari 3. Naasi 4. Khasi Please enter your answer: 1 The answer that you have entered is wrong. The correct answer for the above question is option no. 4. Khasi Question 14: How many number of judges do the Indian Supreme court consist of at present ? 1. 25 judges 2. 20 judges 3. 31 judges 4. 30 judges Please enter your answer: 1 The answer that you have entered is wrong. The correct answer for the above question is 3. 32 Judges Question 15: Out of the following people, who was presented with the Union Budget for maximum number of times ? 1. R K Shanmukham Chetty 2. P. Chidambaram 3. Pranav Mukherjee 4. Morarji Desai Please enter your answer: 2 The answer that you have entered is wrong. The correct answer for the above question is option no. 4. Morarji Desai Question 16: Out of the following people, who is famously known as " flying sikh " ? 1. Milkha Singh 2. Sardar Vallabhbhai Patel 3. Jawaharlal Nehru 4. Lala Lajpat Rai Please enter your answer: 1 Your answer is absolutely correct You score 5 points !! Question 17: Out of the following days, when will the lunar eclipse happen ? 1. On a full moon night 2. On a half moon night 3. On a Sunny day 4. On an Equinox Please enter your answer: 1 Your answer is absolutely correct You score 5 points !! Question 18: Out of the following listed cancers, which cancer is the most common type of cancer that kills male people in the entire world ? 1. Throat Cancer 2. Lung Cancer 3. Liver Cancer 4. Skin Cancer Please enter your answer: 2 Your answer is absolutely correct You score 5 points !! Question 19: Out of the following listed cancers, which cancer occurs within the bone marrow ? 1. Sarcoma 2. Myeloma 3. Leukemia 4. Lymphoma Please enter your answer: 3 Your answer is absolutely correct You score 5 points !! Question 20: Out of the following listed virus, which virus is transmitted through the bite of animals, birds, and insects that are effected with any kind of infections? 1. Ebola virus 2. Rabies virus 3. Flavi virus 4. All of the above Please enter your answer: 2 The answer that you have entered is wrong. The correct answer for the above question is option no. 4. All of the above You have scored 65 points Thank you for your interest !! Player rating: 4/5 下一主题C 语言中的字符串数组 |
我们请求您订阅我们的新闻通讯以获取最新更新。