if语句练习题
- 格式:doc
- 大小:38.00 KB
- 文档页数:2
if从句练习题if从句练习题if从句是英语中非常重要的语法结构之一,它用来表达假设、条件和可能性。
掌握好if从句的用法和运用,对于提高英语的表达能力至关重要。
下面我将给大家提供一些if从句的练习题,希望能帮助大家更好地理解和运用这一语法结构。
练习一:完成下列句子,使用正确的if从句形式。
1. 如果我有足够的时间,我会去看电影。
2. 如果你不努力学习,你就不能通过考试。
3. 如果天气好,我们将去郊游。
4. 如果我是你,我会接受这个机会。
5. 如果我有钱,我会买一辆新车。
练习二:根据给定的情境,完成下列句子,使用正确的if从句形式。
1. 你想要改变现状吗?如果是的话,你应该努力工作。
2. 如果你不告诉我真相,我将无法帮助你。
3. 如果你不早点出发,你会迟到的。
4. 如果你不小心,你会摔倒的。
5. 如果你不去医院,你的病情可能会恶化。
练习三:根据给定的情境,完成下列句子,使用正确的if从句形式。
1. 如果你明天有空,我们可以一起去看电影。
2. 如果你不快点,我们将会错过火车。
3. 如果你不知道答案,你可以向老师请教。
4. 如果你不喜欢这个菜,我可以给你换一个。
5. 如果你迷路了,你可以问路人。
练习四:根据给定的情境,完成下列句子,使用正确的if从句形式。
1. 如果我有机会,我会去旅行。
2. 如果你不小心,你会弄丢钱包的。
3. 如果你不吃早餐,你会感到饿的。
4. 如果你不学习,你将无法通过考试。
5. 如果你不努力工作,你就不能取得成功。
练习五:根据给定的情境,完成下列句子,使用正确的if从句形式。
1. 如果你不锻炼,你的健康状况会变差。
2. 如果你不按时交作业,老师会扣分的。
3. 如果你不小心驾驶,你会出事故的。
4. 如果你不学会这个技能,你将失去这个机会。
5. 如果你不好好休息,你会感到疲劳的。
通过以上练习题,我们可以更好地理解和掌握if从句的用法。
if从句在表达假设、条件和可能性时非常常用,因此我们应该多加练习和运用,以提高我们的英语表达能力。
If 用法练习100题1. We will go shopping if it____ tomorrow.A don't rain B. didn't rain C. doesn't rain D. isn't rain2. The girls asked if they ____ some food and drink with them. A. took B. take C. takes D. will take3. She asked Linda if___ go and get some. A. could she B. she could C. she can D. she may4. I don't know _____ they have passed the exam. A. what B. if C. when D. where5. She didn't know______ back soon.A. whether he would beB. if would he beC. he will beD. if he will come6.I don't know _____ he still lives here after so many years. A. whether B where C. what D. when7.She asked me if I knew ______A. whose pen is itB. whose pen it wasC. whose pen it isD. whose pen was it8.He said ______ there was going to be a meeting that evening. A. what B. if C. that D. how9. The girls asked if they ____ some food and drink with them.A. tookB. takeC. takesD. will take10. The students would have made better grades if they _______hard.A. studyB. studiedC. had studiedD. studying11.Hundreds of jobs _______ if the factory closes.A. loseB. will be lostC. lostD. will lose12. I'll have to push the car to the side of the road because we ____if we leave it here.A. would be finedB. will be finedC. will being finedD. will have been fined13. If one ________by pride, he will reject useful advice and friendly assistance.A. overcomesB. is overcomeC. has been overcomeD. overcome14. Y ou’re at a party and someon e asks if you _______ a good time.A. haveB. hadC. are havingD. will have15. If she had worked harder, she _____ better in the examination.A. might have doneB. had doneC. could doD. should do16. If we meet with a new word ,don't forget to _______in the dictionary.A. look up itB. look for itC. look it upD. look after it17. If you __________here yesterday you would have seen the famous actor.A. wereB. has beenC. had beenD. would be18. _________no electronic computers, they could have been no satellites or rockets.A. Had there beenB. If there wereC. Should there beD. If there are19. ____________,Sam would have been able to pass the exam.A. If he studies moreB. If he were studying to a greater degreeC. Studying moreD. Had he studies more20. If he ________ his homework, Frank can go out for a walk.A. will finishB. finishesC. finishD. to finish21. There will be a lot of spare time if it _________ tomorrow.A. rainsB. rainC. will rainD. is going to rain22. ____ environmental damage is done, it takes many years for the ecosystem to recover.A. Even ifB. If onlyC. WhileD. While23. My parents were quarrelling about me ____ I could not quite tell why.A. sinceB. thoughC. ifD. until24. It is known to all that ____ you exercise regularly, you won’t keep good health.A. unlessB. wheneverC. althoughD. if25. In time of serious accidents, ___ we know some basic things about first aid, we can savelives. A. whether B. until C. if D. unless26. How can you expect to learn anything ____ you never listen?A. in caseB. even ifC. unlessD. when27. We don’t keep winning games ____ we keep playing well.A. becauseB. unlessC. whenD. even if28. ----I have never spoken ill of Mary. ---- you don’t like her.A. IfB. BecauseC. So thatD. Though29. Allow children the space to voice their opinions, they are different from your own.A、until B. even if C. unless D. as though30. ----Will you go to attend her birthday party? ----No, invited to.A. ifB. untilC. whenD. even though31. Y ou must keep on working in the evening, you are sure you can finish the task in time.A、asB、ifC、whenD、unless32. _____ the expense, I _____ to Italy.A. If it were not, goB. Were it not for, would goC. Weren't it for, will goD. If it hadn’t been, would have gone33. If you don't feel well, you may just ___ .A. stopped readingB. stop readingC. stopped to readD. stop to read34. They treated her very well ____one of the family members.A. like B. as C. as if D. seems35. After he won all the money they treated him __a king. A. like B. as C. as if D. seemed36. –Does it matter if I give it up this time? -- It ____if you do. Y ou won’t have ______chance.A. does; the otherB. does ; secondC. does matter; anotherD. does matter; the other37. 1. ____ it rains, the game will be played on time.2. ____ I was twenty, I had never been away from my hometown.3. ____ he were there, he couldn’t help us.A.Even ifB. UntillC. TillD. Unless38. If only he _____ me yesterday! A. had seen B. would see C. should see D. saw39. If you _____ wait a moment, I’ll go and find our manager. A. can B. should C. will D. must40. If I _____ you, I _____ more attention to English idioms and phrases.A. was; shall payB. am; will payC. would be; would payD. were; would pay41. —Who is the girl standing over there? —Well, if you _____ know, her name is Mabel.A. mayB. canC. mustD. shall42. We might have failed if you us a helping hand.A.have not given B.would not give C.had not given D.did not give43. If there were no subjunctive mood,English much easier.A.will be B.would have been C.could have been D.would be44. Y ou are late.If you a few minutes earlier, you him.A.came;Would meet B.had come;Would have metC.come;Will meet D.had come;would meet45. The two strangers talked as if they friends for years.A.should be B.had been C.have been D.were46. If we had not missed the bus,we lunch at home now.A.would have had B.would have C.must be having D.would be having 47. here yesterday,he would attend the lecture with us today.A.Had he been B.If he were C.Were he D.Should be he48. O ur chairman hasn’t come yet.If he on time,we would have to put off the meeting.A.should come B.would come C.shouldn’t come D.doesn’t come49. I her if I thought she would understand.A.would tell B.will tell C.Would have to1d D.told50. —If he ,he that food.—Luckily he was sent to the hospita1 immediate1y.A.Was warmed;would not take B.had been warmed;wou1d not have taken C.would be warmed;had not taken D.would have been warmed;had not taken51. Wouldn't it be ___wonderful world if all nations lived in ___peace with one another?A. a; /B. the; /C. a; theD. the; the52. If I ____ where he lived, I ____ a note to him.A. knew, wouldB. had known, would have sentC. know, would sendD. knew, would have sent53. I didn’t know his telephone number. ____ it, I ____ then.A. Had I known, would ring him upB. Should I know, would have rung him upC. If I knew; would ring him upD. Had I known; would have rung him up54. Mary is ill today. If she _____ , she ____ absent from school.A. were not ill; wouldn’t beB. had been ill; wouldn't have beenC. had been ill; should have beenD. hadn't been ill; could be55. Were I to do it, I ________ it some other way.A. will doB. would doC. would have doneD. were to do56. I ________ him the answer ________ possible, but I was so busy then.A. could tell; if it had beenB. must have told; were itC. should have told; had it beenD. should have told; should it be57. If they ____ earlier than expected, they ____ here now.A. had started, would beB. started, might beC. had started, would have beenD. will start, might have been58. He acted as if he ________ everything in the world.A. knewB. knowsC. has knownD. won't know59. If only I _________ to the lecture! A. listen B. will listen C. am listening D. had listened60. --- If he_____ , he ______ that food. ---- Luckily he was sent to the hospital immediately.A. was warned; would not takeB. had been warned; would not have takenC. would be warned; had not takenD. would have been warned; had not taken61. I didn’t see your sister at the meeting. If she _________, she would have met my brother.A. has comeB. did comeC. cameD. had come62. If city noises _______ from increasing, people _______ shout to be heard even at the dinner table 20 years from now. A. are not kept; will have to B. are not kept; have toC. do not keep; will have toD. do not keep; have to63. If you had enough money, what ________ ?A. will you buyB. would you buyC. would you have boughtD. will you have bought64. If you ________ that film late last night, you wouldn't be so sleepy.A. didn't seeB. haven't seenC. wouldn’t have seenD. hadn’t seen65. I'm going anyway. _____ she will go is up to her to decide.A. If or notB. Whether or notC. IfD. That66. It is still a question _____ we shall have our sports meet. A. if B. that C. what D. when67. It has been decided _____ he will be sent there. A. if B. whether C. why D. that68. It doesn’t matter _____he' s come back or not. A. if B. whether C. that D. when69. ____ the 2000 Olympic Games won't be held in Beijing is known to all.A. WhetherB. IfC. WheneverD. That70. It looked ____.A. as if it was going to rainB. that as if it was going to rainC. as if was it going to rainD. as if that it was going to rain71. My suggestion is _____ we should send a few comrades to help them.A. ifB. thatC. when thatD. that where72. The fact _____ he hadn’t said anything surprised us all. A. why B. if C. that D. whether73. Father made a promise ____ I passed the exam, he would buy me a bicycle.A. thatB. ifC. whetherD. that if74. There is no doubt ____ my friend was not important to them all.A. thatB. whetherC. ifD. why75. If we don’t start out now, we must risk ______ the train.A. miss B missing C. being missed D to miss76. Give me one more minute ____ I’ll be able to finish it.A. andB. orC. ifD. so77. ---- I’d really like some lunch but I have so much work to do.---- ____ what you want and I can get it for you.A. Tell meB. If you would say to meC. Y ou will tell meD. If you tell me78. If they _________ to do this work, he might do it some other way.A. wereB. shouldC. willD. can79. If you were in an English-speaking country, you, too, _________ English every day.A. will be used to speakB. will be used to speakingC. must be used to speakD. would be used to speaking80. ___the headmaster comes, we won’t discuss this plan.A. UnlessB. If notC. ExceptD. Whether81. Don’t be discouraged ________you have fallen behind others.A. whetherB. as ifC. even ifD. however82.We can get there on time ______the car doesn’t break down.A. whileB. as long asC. so thatD. even if83. I’ll start early, _______it may be dark. A. however B. whether C. if D. though84. We shouldn’t do that dangerous experiment _____the teacher is with as.A. if notB. ifC. unlessD. as long as85. This is a revision paper. When you do it, you’d better make a mark _______you have questions.A. whereB. the placeC. as ifD. since86. .--- Don’t look dow n upon Bob. He has his own advantages.--- Oh, yes. ____ others are weak, he is strong. A. If B. When C. Where D. Though87. John shut everybody out of the kitchen _____ he could prepare his grand surprise for the party.A. whichB. whenC. so thatD. as if88. They went on working ________ it was late at night.A. even ifB. as ifC. howeverD. as though89. --- Shall Brown come and play computer games?--- No,________ he has finished his homework. A. when B. if C. unless D. once90. I hurried ___ I wouldn’t be late for class. A. since B. so that C. as if D. unless91. --- Alice is moving to her new apartment next Saturday.--- I would be glad to help her,________ need some help.A. should sheB. if she willC. if sheD. if she might92. I wonder if I ________ time. If I ________ time,I’ll go with you.A. have;haveB. will have;will haveC. have;will haveD. will have;have93. --I’m going to the post office.--______ you're there. can you get me some stamps?A. AsB. WhileC. BecauseD. If94. The WTO can’t live up to its name _____it does not include a country that is a home to one fifth of mankind. A. as long as B. while C. if D. even though95. John shut everybody out of the kitchen _____ he could prepare his grand surprise for the party.A. whichB. whenC. so thatD. as if96. Y ou will be late _____ you leave immediately. A. unless B. until C. if D. or97. I would appreciate it _______ you call back this afternoon for the doctor’s appointment.A. untilB. ifC. whenD. that98. The company has a free long-distance telephone number _____ customers may call with any questions they have about its products. A. although B. as C. even if D. so that 99. ______ the Internet is bringing the distance between people, it may also be breaking some homes or will cause other family problems.A. When B. If C. As D. While 100. The meeting didn't start___ everyone was there. A. because B. until C. why D. if101.May I sit nearer___ I can see more clearly? A. as if B. so that C. even if D. so102 ___ you work hard, you will certainly succeed. A. Though B. If C. Because D. For103. I want to know ___ she is going to see a film. A. if B. that C. what D. which104. Y ou are sure to pass the exam ___ you study hard. A. if B. though C. that D. since105. I'll go to see the film with you___ I have time this evening. A. whether B. so C. if D. when 106. ___ you study harder, you'll never pass the final exam. A. If B. Until C. Unless D. Except 107. The dictionary is so expensive ___ I can't buy it. A. because B. when C. that D. if 108. All plants need air _______they need water. A.like B.as if C.as D.so 109. The old professor worked many hours a day _______he became seriously ill.A. althoughB. even ifC. thoughD. until110. Y ou must keep on working in the evening _______ you are sure you can finish the task in time.A. asB. ifC. whenD. unless111. Allow children the space to voice their opinion, ______ they are different from your own.A. untilB. even ifC. unlessD. as though112. _____ no subjunctive mood, English would be much easier.A. If were thereB. If there wereC. Were thereD. Is there 113. _____ no subjunctive mood, English would be much easier.A. If were thereB. Were if thereC. Were thereD. Is there1) This is an illness that can result in total blindness ______ left untreated.(2) ______ you want me to fire you, I suggest you stop wearing sports clothes at office.(3) You must keep on working in the evening ______ you are sure you can finish the task in time.A. sinceB. ifC. unlessD. until。
(完整版)if虚拟语气练习题及答案如果虚拟语气练习题是一种能够帮助我们巩固和加深对于虚拟语气的理解的方法。
通过解答这些练习题,我们可以更好地掌握虚拟语气的用法,并提高在语言表达中正确运用虚拟语气的能力。
下面提供一些虚拟语气练习题及答案,希望可以帮助大家加深对虚拟语气的认识。
练习题一:填空题根据句意,选择正确的虚拟语气形式填空。
1. 如果我______(知道)你的电话号码,我会给你打电话。
答案:知道2. 如果我______(是)你,我会接受这个机会。
答案:是3. 如果他______(尽力)的话,他会取得更好的成绩。
答案:尽力4. 如果我______(有)足够的钱,我会帮助他。
答案:有5. 如果我______(做)得更好一些,我就能拿到这个工作了。
答案:做6. 如果明天______(不下雨),我们可以去野餐。
答案:不下雨7. 如果他______(不是)这么懒,他就不会被开除了。
答案:不是8. 如果你______(去)采取行动,你将失去这个机会。
答案:去9. 如果他______(读)更多的书,他的知识会更丰富。
答案:读10. 如果我______(拥有)魔法,我将会改变世界。
答案:拥有练习题二:选择题选择最佳答案填空。
1. 如果我______(会)弹钢琴,我会给你弹一首歌。
a. 会b. 能c. 可以d. 有答案:a. 会2. 如果你______(是)我,你会怎么做?a. 是b. 是的c. 如果d. 可以答案:a. 是3. 如果明天______(没有)下雨,我们可以去郊游。
a. 没有b. 不下c. 不下雨d. 不来答案:c. 不下雨4. 如果他______(学习)更努力,他会取得更好的成绩。
a. 学习b. 学习了c. 学习过d. 学习到答案:a. 学习5. 如果我______(有)足够的钱,我会买一辆新车。
a. 有b. 拥有c. 会有d. 有着答案:a. 有练习题三:改错题找出下列句子中的错误,并进行改正。
英语if专题练习题### If Conditionals Practice ExercisesConditional sentences are an essential part of English grammar, expressing different possibilities and outcomes based on certain conditions. Here are some exercises to help you practice using "if" in various scenarios.#### Exercise 1: Fill in the blanks with the correct form of the verb.1. If it rains tomorrow, we will stay at home.2. If you study hard, you will pass the exam.3. If she had known the truth, she would have told us.4. If he offers you a job, you should consider it.5. If I had enough money, I would travel around the world.#### Exercise 2: Rewrite the sentences using the correct "if" clause.1. We will go to the party if we finish our work early.- We will go to the party if we finish our work early.2. She would have been happy if she had received the gift.- She would have been happy if she had received the gift.3. They will help us if we ask them nicely.- They will help us if we ask them nicely.4. I would have called you if I had your number.- I would have called you if I had your number.5. He will be late if he misses the bus.- He will be late if he misses the bus.#### Exercise 3: Choose the correct answer to complete the sentences.1. If I had taken the medicine, I wouldn't have felt sick.- A) had taken B) take C) would take2. She will call you if she finds your phone number.- A) if she finds B) unless she finds C) because she finds 3. They will win the game if they practice more.- A) if they practice B) unless they practice C) because they practice4. I would have gone with you if I had known about the trip. - A) if I had B) if I have C) because I had5. He will succeed if he works hard.- A) if he works B) unless he works C) because he works#### Exercise 4: Write a short paragraph using "if" conditionals.Imagine you are planning a surprise party for your friend. Write a paragraph about what you would do if certain conditions were met.If our friend agrees to go out for dinner, we will set up the party at her house while she is away. If we can't get a hold of her, we will have to think of another plan. If she finds out about the surprise, it won't be as special, so we must ensure everyone keeps it a secret. If we manage to execute our plan perfectly, it will be a birthday party she will never forget.#### Exercise 5: Answer the following questions using "if" conditionals.1. What would you do if you won the lottery?2. How would you react if you were given a promotion at work?3. What would happen if it snowed heavily during the winter?4. What would you do if you had a day off without any plans?5. How would you feel if you were invited to a prestigious event?These exercises are designed to help you understand and apply "if" conditionals in various contexts. Practice makes perfect, so keep working through these exercises to improve yourEnglish skills.。
if条件句练习题及答案一、选择题1. 如果明天不下雨,我们将去野餐。
A) If it doesn't rain tomorrow, we will go for a picnic.B) If it rains tomorrow, we will go for a picnic.C) If it will rain tomorrow, we will go for a picnic.D) If it rains tomorrow, we will not go for a picnic.2. 只有当我完成作业后,我才会看电视。
A) I will watch TV only after I finish my homework.B) I will watch TV only before I finish my homework.C) I will watch TV only while I finish my homework.D) I will not watch TV only after I finish my homework.3. 除非他道歉,否则我不会原谅他。
A) I will forgive him unless he apologizes.B) I will not forgive him unless he apologizes.C) I will forgive him if he does not apologize.D) I will not forgive him if he apologizes.4. 只要我们努力工作,我们就能成功。
A) We can succeed as long as we work hard.B) We can succeed unless we work hard.C) We can succeed if we do not work hard.D) We cannot succeed unless we work hard.5. 如果你饿了,冰箱里有食物。
if条件句练习题及答案If条件句练习题及答案If条件句是英语语法中非常重要的一部分,它用来表达假设或条件。
以下是一些if条件句的练习题及答案,希望能帮助大家更好地掌握这一语法知识。
练习题一:用正确的if条件句填空。
1. If I __________ (have) enough money, I would buy a new car.2. If it __________ (rain) tomorrow, we will stay at home.3. If she __________ (study) harder, she would pass the exam.4. If he __________ (not be) late, we would have caught the train.答案:1. had2. rains3. studied4. had not been练习题二:选择正确的if条件句。
1. If I had studied harder, I __________ the exam.a) would have passedb) will passc) passd) passed2. If it rains tomorrow, we __________ our picnic.a) will cancelb) would cancelc) canceld) cancelled3. If you had told me earlier, I __________ helped you.a) willb) wouldc) would haved) had答案:1. a) would have passed2. a) will cancel3. c) would have练习题三:根据给定的情景写出合适的if条件句。
1. 你的朋友迟到了,你会怎么说?If you had left home earlier, you wouldn't have missed the bus.2. 你想和朋友一起去看电影,但天气可能会下雨,你会怎么说? If it rains tomorrow, we will stay at home and watch a movie.3. 你没有通过考试,你会怎么安慰自己?If I had studied harder, I would have passed the exam.答案:1. If you had left home earlier, you wouldn't have missed the bus.2. If it rains tomorrow, we will stay at home and watch a movie.3. If I had studied harder, I would have passed the exam.希望以上练习题和答案能帮助大家更好地理解和掌握if条件句的用法。
if条件状语从句练习题及答案If条件状语从句练习题及答案条件状语从句是英语中常用的一种从句结构,用来表示某个条件成立时,另一个事件或结果也将发生。
掌握条件状语从句的用法对于提高英语口语和写作能力非常重要。
下面将给出一些条件状语从句的练习题及答案,帮助读者更好地理解和掌握这一语法知识。
练习题一:1. If it rains tomorrow, ___________.2. She will be late for work if ___________.3. If I see him, ___________.4. If you don't study hard, ___________.5. If I were you, ___________.练习题二:1. If you ___________ to the party, please bring a gift.2. If I ___________ you, I would apologize.3. If she ___________ the exam, she will be very happy.4. If it ___________ tomorrow, we will go hiking.5. If he ___________ the bus, he will be late for the meeting.答案一:1. we will stay at home.2. she misses the bus.3. I will say hello.4. you will fail the test.5. I would study harder.答案二:1. come2. were3. passes4. doesn't rain5. misses通过以上练习题,我们可以发现条件状语从句的用法和特点。
首先,在条件状语从句中,通常使用的连词有if、unless、provided that等。
第五章if语句练习题1.已知int x=10,y=20,z=30;以下语句执行后x,y,z的值是____ ____ _if(x>y)z=x;x=y;y=z;2.以下if语句语法正确的是________A.if(x>0)printf(“%f”,x)else printf(“%f”,-x);B.if(x>0){x=x+y;printf(“%f’,x);}else printf(“%f”,-x);C.if(x>0){x=x+y;printf(“%f”,x);}else printf(“%f”,-x);D.if(x>0){x=x+y;printf(“%f,x);}else printf(“%f”,-x);3.请阅读以下程序:main( ){int a=5,b=0,c=0;if(a=b+c)printf(“* * *\n”);elseprintf(“$ $ $\n”);}以上程序______A.有语法错不能通过编译B.可以通过编译但不能通过连接C.输出* * *D.输出$ $ $4.以下程序的运行结果是______main( ){int m=5;if(m++>5)printf(“%d\n”,m);else printf(“%d\n”,m--);}A. 4B. 5C. 6D. 75.当a=1,b=3,c=5,d=4时,执行完下面一段程序后x的值是______if(a<b)if(c<d) x=1;elseif(a<c)if(b<d)x=2;else x=3;else x=6;else x=7;A. 1B. 2C. 3D. 66.有一个函数关系见下表:下面程序段中能正确表示上面关系的是( )A. y=x+1;if(x>=0)if(x==0)y=x;else y=x-1;B. y=x-1;if(x!=0)if(x>0)y=x+1;else y=x;C. if(x<=0)if(x<0)y=x-1;else y=x;else y=x+1;D.y=x;if(x<=0)if(x<0)y=x-1;else y=x+1;7.以下程序的输出结果是______ main( ){int a=100,x=10,y=20,okl=5,ok2=0; if(x<y)if(!ok1)a=1;elseif(ok2)a=10;a=-1;printf(“%d\n”,a);}A.1B.0C.-1D.值不确定8.以下程序输出结果是_______ main( ){int x=2,y=-1,z=2;if(x<y)if(y<0) z=0;else z+=1;printf(“%d\n”,z);A.3B.2C.1D.09.以下不正确的语句为______A.if(x>y);B.if(x=y)&&(x! =0) x+=y;C,if(x! =y) scanf(“%d”,&x);else scanf(“%d”,&y);D.if(x<y){x++;y++;}10.阅读以下程序#include<stdio.h>main( ){float a, b;scanf(“%f”,&a);if(a<0.0)b=0.0;else if((a<0.5)&&(a!=2.0))b=1.0/(a+2.0);else if(a<10.0)b=1.0/a;else b=10.0;printf(“%f\n”,b);}若运行时输入2.0<回车>,则上面程序的输出结果是_____A.0.000000B.0.500000C.1.000000D.0.25000011.若运行时输入:16<回车>,则以下程序的运行结果是( )#include<stdio.h>main( ){int year;printf(“Input you year:”);scanf(“%d”,&year);if(year>=18)printf(“you$4.5yuan/xiaoshi”);else printf(“your$3.0yuan/xiaoshi”);}12.若运行时输入:2<回车>,则以下程序的运行结果是( )#include<stdio.h>main( ){char class;scanf(“%c”,&class);if(class==’1’)printf(“1st class postage is 19p”); elseprintf(“2nd class postage is 14p”);}13.若运行时输入:4.4<回车>,则以下程序的运行结果是( ) #include<stdio.h>main( ){float costprice,sellingprice;printf(“enter cost price $:”);scanf(“%f”,&costprice);if(costprice>=5){sellingprice=costprice+costprice*0.25;printf(“selling price(0.25)$%6.2f”,sellingprice);}else{sellingprice=costprice+costprice*0.30;printf(“selling price(0.30)$%6.2f”,sellingprice);}}14.以下程序的运行结果是( )main( ){ if(2*2= =5<2*2= =4) printf(“T”);else printf(“F”);}15.请阅读以下程序:main( ){int t,h,m;scanf(“%d”,&t);h=(t/100)%12;if(h= =0) h=12;printf(“%d:”,h);m=t%100;if(m<10)printf(“0”);printf(“%d”,m);if(t<1200||t= =2400)printf(“AM”);else printf(“PM”);}若运行时输入:1605<回车>时,程序的运行结果是( )16.以下程序实现:输入圆的半径r和运行标志m,按照运行标志进行指定计算.请在( )内填入正确的内容. 标志运算a 面积c 周长b 二者均计算#define pi 3.14159main( ){char m;float r,c,a;printf(“input mark a c or b&&r\n”);scanf(“%c%f”,&m,&r);if( ){a=pi*r*r;printf(“area is %f”,a);}if( ){c=2*pi*r;printf(“circle is %f”,c);}if( ){a=pi*r*r;c=2*pi*r;printf(“area&&circle are%f%f”,a,c);}}17.若运行时输入:5999<回车>,则以下程序的运行结果(保留小数后一位)是( )main( ){int x;float y;scanf(“%d”,&x);if(x>=0&&x<=2999)y=18+0.12*x;if(x>=3000&&x<=5999)y=36+0.6*x;if(x>=6000&&x<=10000)y=54+0.3*x;printf(“%6.1f”,y);}18.以下程序实现输出x,y,z三个数中的最大者.请在( )添入正确内容.main( ){int x=4,y=6,z=7;int ( )if( )u=x;else u=y;if( )v=u;else v=z;printf(“v=%d”,v);}19.以下程序实现:输入三个整数,按从大到小的顺序进行输出.请在( )内填入正确内容main( ){int x,y,z,c;scanf(“%d%d%d”,&x,&y,&z);if( ){c=y;y=z;z=c;}if( ){c=x;x=z;z=c;}if( ){c=x;x=y;y=c;}printf(“%d,%d,%d”,x,y,z);}20.以下程序对输入的两个整数,按从大到小顺序输出.请在( )内填正确内容.main ( ){int x,y,z;scanf(“%d,%d,”,&x,&y);if( ){z=x; }printf(“%d,%d”,x,y);}21.以下程序对输入的一个小写字母,将字母循环后移5个位置后输出.如’a’变成’f’,’w’变成’b’.请在( )填入正确内容#include “stdio.h”main( ){char c;c= ;if(c>=’a’&&c<=’u’)else if(c>=’v’&&c<=’z’)putchar(c);}22.输入一个字符,如果它是一个大写字母,则把它变成小写,如果是小写,则变成大写,其他字符不变,请在( )填正确内容main ( ){char ch;scanf(“%c”,&ch);if( )ch=ch+32; else if(ch>=’a’&&ch<=’z’)(2) printf(“%c”,ch);}23.以下程序的运行结果是( ) main( ){int a,b,c;int s,w,t;s=w=t=0;a=-1,b=3,c=3;if(c>0)s=a+b;if(a<=0){if(b>0)if(c<=0)w=a-b;}else if(c>0)w=a-b;else t=c;printf(“%d%d%d”,s,w,t);}24.以下程序的运行结果是( ) main( ){int a,b,c,d,x;a=c=0;b=1;d=20;if(a)d=d-10;else if(! b)if(! c)x=15;else x=25;printf(“%d\n”,d);}25.以下程序的运行结果是( )#include<stdio.h>main( ){int x,y=1,z;if(y!=0)x=5;printf(“\t%d\n”,x);if(y= =0)x=4;else x=5;printf(“\t%d\n”,x);x=1;if(y<0)if(y>0)x=4;else x=5;printf(“\t%d\n”,x);}26.以下程序的运行结果是( ) #include<stdio.h>main( ){int x,y=-2,z=0;if((z=y)<0)x=4;else if(y= =0)x=5;else x=6;printf(“\t%d\t%d\n”,x,z); if(z=(y= =0))x=5;x=4;printf(“\t%d\t%d\n”,x,z); if(x=z=y)x=4;printf(“\t%d\t%d\n”,x,z);} 27.阅读下面程序:main ( ){int s,t,a,b;scanf(“%d,%d”,&a,&b);s=1;t=1;if(a>0)s=s+1;if(a>b)t=s+t;else if(a= =b)t=5;else t=2*s;printf(“s=%d,t=%d”,s,t);}为使输出结果t=4,输入量a和b应满足的条件是( )28.请阅读下面程序:main( ){int s ,t,a,b;scanf(“%d,%d”,&a,&b);s=1;t=1;if(a>0)s=s+1;if(a>b)t=s+t;else if(a= =b)t=5;else t=2*s;printf(“s=%d,t=%d”,s,t);}为使输出结果s=1,t=5,输入量a和b应满足条件是( )29.下面程序根据以下函数关系,对输入的每个x值,计算出y值,在( )填正确内容main( ){int x,y;scanf(“%d,&x);if(1)y=x*(x+2);else if(2)y=2*x;else if(x<=-1)y=x-1;else( 3 );if(y!=-1)printf(“%d”,y);else printf(“error”);}30.下面程序根据以下函数关系,对输入的每个x值,计算出相应的y值.在( ) 填正确内容#include “math.h”main( ){int x,a;float y;scanf(“%d%d”,&x,&a);if( )y=0;else if( )y=sqrt(a*a-x*x);else y=x;printf(“%f”,y);}31.以下程序的功能是计算一元二次方程ax2+bx+c=0的根,在( )填正确内容#include “math.h”main( ){float a,b,c,t,disc,twoa,term1,term2;printf(“enter a,b,c:”);scanf(“%f%f%f”,&a,&b,&c);if( )if( )printf(“no answer due to input error\n”);else printf(“the single root is%f\n”,-c/b);else{disc=b*b-4*a*c;twoa=2*a;terml=-b/twoa;t=abs(disc);term2=sqrt(t)/twoa;if(3)printf(“complex root\n real part=%fimag part=%f\n”, terml,term2);else printf(“real roots\n rootl=%froot2=%f\n”,terml+term2,term1-term2);}}32.以下程序根据输入的三角形的三边判断是否能组成三角形,若可以则输出它的面积和三角形的类型.在( )填正确内容.#include“math.h”main( ){float a,b,c;float s,area;scanf(“%f %f %f”,&a,&b,&c);if( ){s=(a+b+c)/2;area=sqrt(s*(s-a)*(s-b)*(s-c));printf(“%f”,area);if( )printf(“等边三角形”);else if( )printf(“等腰三角形”);else if((a*a+b*b= =c*c)| |(a*a+c*c= =b*b)| |(b*b+c*c= =a*a) )printf(“直角三角形”);else printf(“一般三角形”);}else printf(“不能组成三角形”);}33.某邮局对邮寄包裹有如下规定:若包裹的长宽高任一尺寸超过1米或重量超过30千克,不予邮寄;对可以邮寄的包裹每件收手续费0.2元,再加上根据下表按重量wei计算的资料:重量(千克) 收费标准(元/公斤)wei<=10 0.8010<wei<=20 0.7520<wei<=30 0.70请在程序的[ ]内填入正确的内容.main( ){float len,wei,hei,wid,mon,r;scanf(“%f %f %f %f”,&len,&wid,&hei,&wei);if(len>1| |wid>1| |hei>1| |wei>30);else if(wei<10) r=0.8;else if(wei<=20) r=0.75;else if(wei<=30);if(r= =-1)printf(“error\n”):else{ ;printf(“%f”,mon);}}34.以下程序的功能是判断输入的年份是否是闰年.请在[ ]内填入正确的内容.main( ){int y,f;scanf(“%d”,&y);if(y%400= =0) f=1;else if( ) f=1;else ;if(f)printf(“%d is”,y);else printf(“%d is not”,y);printf(“a leap year\n”);}35.有四个数a, b, c, d,要求按从大到小的顺序输出.请在[ ]内填入正确内容main( ){int a,b,c,d,t;scanf(“%d %d %d %d”,&a,&b,&c,&d);if(a<b){t=a;a=b;b=t;}if ( ){t=c;c=d;d=t;}if(a<c){t=a;a=c;c=t;}if( ){t=b;b=c;c=t;}if(b<d){t=b;b=d;d=t;}if(c<d){t=c;c=d;d=t;}printf(“%d %d %d %d\n”,a,b,c,d);}36.以下程序的运行结果是__main( ){int a=2,b=3,c;c=a;if(a>b)c=1;else if(a= =b)c=0;else c=-1;printf(“%d\n”,c);}37.在if后一对圆括号中表示a不等于0的关系,则能正确表示这一关系的表达式为_______。
if虚拟语气练习题及答案※错综虚拟条件句,主句,从句时间不一致▲含蓄虚拟语气,省略if 条件句1. If I __ you, I __ worry.A.were/ wouldn’tB.was/ wouldn’tC.been/ would haveD.be/ would2. ___, I would take an umbrella with me.A. Had I been youB. I were youC. Were I youD.I had been you3. If it ___ tomorrow, what would we do?A. rainsB. were to rainC. would rainD. rain4. ___ today, he would get there by Friday.A. Would he leaveB. Was he leavingC. Were he to leaveD. If he leaves .5. ____ to the doctor right away, he might have been alive.A. If he wentB. Were he goneC. Should he have goneD. Had he gone6. If we ____ here ten minutes earlier, we ___ the bus.A. arrived/would catchB. arrived/would have caughtC. had arrived/had caughtD. had arrived/would have caught7.If he had not gone out in the storm _____.A.he will be alive nowB.he would be alive nowC.he would have been alive now8. We ___ our lives had it not been for the policeman.A. would have lostB. should loseC. might loseD. could lose9. If he___to the teacher attentively just now, he___the answer now.A. had listened, would have knownB. listened, would knowC. listened, would have knownD. had listened, would know .10. Had I known her name, ___.A. I should invite her to lunchB. I would invite her to lunchC. I had invited here to lunchD. I would have invited her to lunch11. I would have come earlier, but I ___ that you were waiting for me.A. didn’t knowB. hadn’t knowC. would have knownD. haven’t known12. I was busy yesterday, otherwise I ___ your birthday party.A. attendedB. had attendedC. would attendD. would have attended高中英语if虚拟语气练习题1. If only he ____quietly as the doctor instructed, he would not suffer so much now.A. liesB. layC. had lainD. should lie2. You did not let me drive. If we ____in turn, you ____ so tiredA. drove; didn’t getB. drove; wouldn’t getC. were driving; wouldn’t getD. had driven ; wouldn’t have got3. _____it rain tomorrow, we would have to put off the visit to the Yangpu BridgeA. WereB. ShouldC. WouldD. Will4. I was ill that day, otherwise I ____ the sports meeting.A. would have taken part inB. took part inC. had taken part inD. would take part in5. ___the clouds, you would find the airplane in the sky easilyA. Had it not been forB. If it were notC. If it had not been forD. Were it not for6. If my lawyer ____here last Sunday, he ____ me from going there.A. had been, would have preventedB. had been, would preventC. were, preventD. were, would have prevented7. ____hard, he would have passed the examA. If he were to workB. Had he workedC. Should he workD. Were he to work8. ____today, he would get there by FridayA. Were he to leaveB. If he had leftC. Did he to leave9. Had you listened to the doctor, you ____all right nowA. areB. wereC. would beD. would have been D. Had he left10. I did not see your sister at the meeting. If she ____, she would have met my brotherA. has comeB. did comeC. comeD. had come11. He ____busy yesterday, or he ___you with your experiment.A. was, had helpedB. was, would have helpedC. had been, would have helpedD. were, would have helped12. If it ____for the snow, we____ the mountain yesterdayA. were not, could have climbB. were not, could climbC. had not been, could have climbedD. hadn’t been, could climb13. Without electricity, human life ____quite difficult todayA. isB. will beC. would have beenD. would be14. If only I ___my carA. hadn’t lostB. wouldn’t loseC. didn’t loseD. haven’t lost15. But for water, it ____impossible to live in the earthA. isB. wouldC. wereD. wouldn’t be16. If the hurricane had happened during the day-time, ____more deathsA. it would have beenB. it would beC. there would beD. there would have been17. What the customers_____ from the company is that the goods ____ right to their homes.A. requested, deliverB. demand, be deliveredC. request, should deliverD. demand, delivered18. If law-breakers _____ the society will be in disorderA. made unpunishedB. came unpunishedC. went unpunishedD. not punished19. We took a taxi to the airport. Otherwise we ____lateA. would beB. wereC. will beD. would have been20. As you know, I am a disabled man, but I would be happy if I ___of service to youA. amB. have beenC. should beD. would be21. I did not see your sister at the meeting. If she ____, she would have met my brotherA. has comeB. did comeC. had comeD. came22. If it _____the snow, we _____the Simian Mountain last weekA. were not, could have climbedB. were not,could climbC. had not been, could have climbedD. had not been, could climb23. If I were you, I _____ the chance to go abroad.A. will seizeB. would have seizedC. seizeD. would seize24. Should it rain tomorrow, we ______ climbing.A. wouldn’t have goneB. won’t goC. wouldn’t goD. don’t go25. But for the English examination I to the concert last Sunday.A. would have goneB. will goC. should goD. wentmy advice, he wouldn’t have lost his job.A. followedB. should followC. had followedD. would followhim.A. should tellB. tellsC. toldD. had told28. But for the help of my English teacher, I Writing Competition.A. would not winB. would not have wonC. would winD. would have won29. If we ___ the other road, we might have arrived here in time for the meeting.A. takeB. had takenC. tookD. have takenwould have been saved.A. Have I knownB. If I have knownC. If I knewD. Had I knownA. answeredB. would answerC. had answeredD. would have answered32.If it were not for the fact that you __ ill,I would ask you to do this right now.A. wereB. had beenC. areD. should be.33. If you_____ my advice, you_____ your failure now.A. took; wouldn’t cry overB. had taken; wouldn’t have cried overC. had taken; aren’t crying overD. had taken; wouldn’t be crying over34. ______ your timely warning, we would have been unaware of the danger.A. In spite ofB. But forC. Instead ofD. As for your call.35. The girl is seriously ill, otherwise she bed all day long.A. is stillB. will still beC. would still beD. was still36. -Mike,it’s a pity you didn’t come to last night’s concert.It was really great! -Really? If I _____ so busy,1 would have gone with you.A. hadn’t beenB. weren’tC. shouldn’t beD. wouldn’t be37. -Mary looks sad and disappointed-Soyou if you had failed the NMET .A. doB. didC. willD. wouldA . wouldn’t make B. wouldn’t have madeC. hadn’t madeD. didn’t make39.A. If you hadB. Had you notC. Hadn’t youD. If you wouldn’t have40. Had you listened to the doctor, you _____ all right now.A. areB. wereC. would beCDBADABACDBCDAC DBCDACCDCACDBBDDCDBC ADBCC D. would have been☆虚拟的倒装:提前had,should,were 省略if※错综虚拟条件句,主句,从句时间不一致▲含蓄虚拟语气,省略if 条件句1. If I __ you, I __ worry.A.were/ wouldn’tB.was/ wouldn’tC.been/ would haveD.be/ would2. ___, I would take an umbrella with me.A. If I Had been youB. I were youC. If I were youD. I had been you3. If it ___ tomorrow, what would we do?A. rainsB. were to rainC. would rainD. rain4. ___ today, he would get there by Friday.A. Would he leaveB. Was he leavingC. If he were to leaveD. If he leaves .5. ____ to the doctor right away, he might have been alive.A. If he wentB. Were he goneC. Should he have goneD. If he had gone6. If we ____ here ten minutes earlier, we ___ the bus.A. arrived/would catchB. arrived/would have caughtC. had arrived/had caughtD. had arrived/would have caught7.If he had not gone out in the storm _____.A.he will be alive nowB.he would be alive nowC.he would have been alive now8. We ___ our lives if it had not been for the policeman.A. would have lostB. should loseC. might loseD. could lose9. If he___to the teacher attentively just now, he___the answer now.A. had listened, would have knownB. listened, would knowC. listened, would have knownD. had listened, would know .10. If I had known her name, ___.A. I should invite her to lunchB. I would invite her to lunchC. I had invited here to lunchD. I would have invited her to lunch虚拟语气练习题1. If I ____ where he lived, I ____ a note to him.A. knew, wouldB. had known, would have sentC. know, would sendD. knew, would have sent2. If they ____ earlier than expected, they ____ here now.A. had started, would beB. started, might beC. had started, would have beenD. will start, might have been3. I didn’t know his telephone number. ____ it,I ____ then.A. Had I known, would ring him upB. Should I know, would have rung him upC. If I knew; would ring him upD. Had I known; would have rung him up4. Mary is ill today. If she _____, she ____ absent from school.A. were not ill,wouldn’t beB. had been ill,wouldn’t have beenC. had been ill, should have beenD. hadn’t been ill, could be5. Were I to do it, I ________ it some other way.A. will doB. would doC. would have doneD. were to do9. We wish we ____ what you did when we were at high school.A. didB. could have doneC. have doneD. should do10. She wishes she ____ to the theatre last night.A. wentB. would goC. had goneD. were going11. Tom is very short now. His mother wishes that he ________ be tall when he grows up.A. couldB. shouldC. wouldD. were able to26. —— If he_____, he ______ that food.---- Luckily he was sent to the hospital immediately.A. was warned, would not takeB. had been warned, would not have takenC. would be warned, had not takenD. would have been warned, had not taken27. I didn’t see your sister at the meeting. If she _________, she would have met my brother.A. has comeB. did comeC. cameD. had come30. If city noises _______ from increasing,people _______ shout to be heard even at the dinner table0 years from now.A. are not kept, will have toB. are not kept, have toC. do not keep, will have toD. do not keep, have to34. If you had enough money, what ________?A. will you buyB. would you buyC. would you have boughtD. will you have bought35. If you ________ that film late last night,you wouldn’t be so sleepy.A. didn’t seeB. haven’t seenC. wouldn’t have seenD. hadn’t seen1~BADAB ~10 CDABC 11~1CCDDB 16~20 ADAAC 1~2DCDAD~30 BDDAA31~3DABBD~40 DABDC。
If条件句练习:一.用if连接下列句子:1.It rains tomorrow.We won’t go for a picnic.If it rains tomorrow, we won’t go for a picnic.2.The children come home early.They will play in the garden. If the children come home early, they will play in the garden.3.He has a lot of money.He will buy a new car.If he has a lot of money,he will buy a new car.4.I am free.I’ll come here.If I am free, I’ll come here.5.He is rich.He will live abroad.If he is rich, he will live abroad.二.翻译下列句子:1.如果你摔下来,你会伤到自己。
If you fall, you’ll hurt yourself.2.如果我错过了公交车,我就坐车租车。
If I miss the bus, I’ll take a taxi.3.如果你明天病了,你就别去上班了。
If you are sick tomorrow, don’t go to work.4.如果他有很多钱,他就坐飞机去纽约。
If he is rich, he’ll go to New York by plane.5.如果他们给你更多的钱,你会做什么?If they give you more money, what will you do?。
if语句练习题1.以下不正确的if语句形式是______A)if(x>y&&x!=y);B)if(x= =y)x+=y;C)if(x!=y)scanf(“%d”,&x),else scanf(“%d,&y);D)if(x<y){x++;y++;}2.以下运算符中优先级最低的是(1),优先级最高的是(2)A) ?: B)&& C)+ D)! =3.已知int x=10,y=20,z=30;以下语句执行后x,y,z的值是_____ if(x>y)z=x;x=y;y=z;A)x=10,y=20,z=30 B)x=20,y=30,z=30C)x=20,y=30,z=10 D)x=20,y=30,z=204.以下if语句语法正确的是_____A)if(x>0)printf(“%f”,x)else printf(“%f”,-x);B)if(x>0){x=x+y;printf(“%f’,x);}else printf(“%f”,-x);C)if(x>0) {x=x+y;printf(“%f”,x);}else printf(“%f”,-x);D)if(x>0){x=x+y;printf(“%f,x);}else printf(“%f”,-x);5.请阅读以下程序:main( ){int a=5,b=0,c=0;if(a=b+c)printf(“* * *\n”);else printf(“$ $ $\n”);}以上程序______A)有语法错不能通过编译 B)可以通过编译但不能通过连接C)输出* * * D)输出$ $ $6.以下程序的运行结果是______main( ){int m=5;if(m++>5)printf(“%d\n”,m);else printf(“%d\n”,m--);}A) 4 B) 5 C) 6 D) 77.当a=1,b=3,c=5,d=4时,执行完下面一段程序后x的值是______ if(a<b)if(c<d) x=1;elseif(a<c)if(b<d)x=2;else x=3;else x=6;else x=7;A) 1 b) 2 c) 3 d) 68. 有一个函数关系见下表:下面程序段中能正确表示上面关系的是( ) A) y=x+1;if(x>=0)if(x==0)y=x;else y=x-1;b) y=x-1;if(x!=0)if(x>0)y=x+1; else y=x;c) if(x<=0)if(x<0)y=x-1;else y=x;else y=x+1;d)y=x;if(x<=0)if(x<0)y=x-1;else y=x+1;9.以下程序的输出结果是______main( ){int a=100,x=10,y=20,okl=5,ok2=0;if(x<y)if(!ok1)a=1;elseif(ok2) a=10;a=-1;printf(“%d\n”,a);}A 1B 0C -1D 值不确定10.以下程序输出结果是_______main( ){int x=2,y=-1,z=2;if(x<y)if(y<0) z=0;else z+=1;printf(“%d\n”,z);A.3B.2C.1D.011.为避免在嵌套的条件语句if-else中产生二义性,C语言规定:else子句总是与___配对.A.缩排位置相同的ifB.其之前最近的ifC.其之后最近的ifD.同一行上的if12.以下不正确的语句为______A.if(x>y);B.if(x=y)&&(x! =0) x+=y;C,if(x! =y)scanf(“%d”,&x);else scanf(“%d”,&y);D.if(x<y){x++;y++;}12.阅读以下程序#include<stdio.h>main( ){float a, b;scanf(“%f”,&a); if(a<0.0)b=0.0;else if((a<0.5)&&(a!=2.0))b=1.0/(a+2.0);else if(a<10.0)b=1.0/a;else b=10.0;printf(“%f\n”,b);}若运行时输入2.0<回车>,则上面程序的输出结果是_____A)0.000000 B)0.500000 C)1.000000 D)0.25000013.若运行时输入:16<回车>,则以下程序的运行结果是( )#include<stdio.h>main( ){int year;printf(“Input you year:”);scanf(“%d”,&year);if(year>=18)printf(“you$4.5yuan/xiaoshi”);else printf(“your$3.0yuan/xiaoshi”);}14.若运行时输入:2<回车>,则以下程序的运行结果是( )#include<stdio.h>main( ){char class;printf(“enter 1for 1stclass post or 2 for 2nd post”);scanf(“%c”,&class);if(class= =’1’) printf(“1st class postage is 19p”); else printf(“2nd class postage is 14p”);}15.若运行时输入:4.4<回车>,则以下程序的运行结果是( ) #include<stdio.h>main( ){float costprice,sellingprice;printf(“enter cost price $:”);scanf(“%f”,&costprice);if(costprice>=5){sellingprice=costprice+costprice*0.25;printf(“selling price(0.25)$%6.2f”,sellingprice);} else{sellingprice=costprice+costprice*0.30;printf(“selling price(0.30)$%6.2f”,sellingprice);}} 16.以下程序的运行结果是( )main( ){ if(2*2= =5<2*2= =4) printf(“T”);else printf(“F”);}17.请阅读以下程序:main( ) {int t,h,m;scanf(“%d”,&t);h=(t/100)%12;if(h= =0)h=12;printf(“%d:”,h);m=t%100;if(m<10)printf(“0”);printf(“%d”,m);if(t<1200||t= =2400)printf(“AM”);else printf(“PM”);}若运行时输入:1605<回车>时,程序的运行结果是( )18.以下程序实现:输入圆的半径r和运行标志m,按照运行标志进行指定计算.请在( )内填入正确的内容.标志运算a 面积c 周长b 二者均计算#define pi 3.14159main( ){char m;float r,c,a;printf(“input mark a c or b&&r\n”);scanf(“%c%f”,&m,&r);if( 1 ){a=pi*r*r;printf(“area is %f”,a);}if( 2 ){c=2*pi*r;printf(“circle is %f”,c);}if( 3 ){a=pi*r*r;c=2*pi*r;printf(“area&&circle are%f%f”,a,c);}}19.若运行时输入:5999<回车>,则以下程序的运行结果(保留小数后一位)是( ) main( ){int x;float y;scanf(“%d”,&x);if(x>=0&&x<=2999)y=18+0.12*x;if(x>=3000&&x<=5999)y=36+0.6*x;if(x>=6000&&x<=10000)y=54+0.3*x;printf(“%6.1f”,y);}20.以下程序实现输出x,y,z三个数中的最大者.请在( )添入正确内容.main( ){int x=4,y=6,z=7; int ( 1 )if( 2 )u=x;else u=y;if( 3 )v=u;else v=z;printf(“v=%d”,v);}21.以下程序实现:输入三个整数,按从大到小的顺序进行输出.请在( )内填入正确内容main( ){int x,y,z,c;scanf(“%d%d%d”,&x,&y,&z);if( 1 ){c=y;y=z;z=c;}if( 2 ){c=x;x=z;z=c;}if( 3 ){c=x;x=y;y=c;}printf(“%d,%d,%d”,x,y,z);}22.以下程序对输入的两个整数,按从大到小顺序输出.请在( )内填正确内容.main ( ){int x,y,z;scanf(“%d,%d,”,&x,&y);if( 1 ){z=x;(2)}printf(“%d,%d”,x,y);}23.以下程序对输入的一个小写字母,将字母循环后移5个位置后输出.如’a’变成’f’,’w’变成’b’.请在( )填入正确内容#include “stdio.h”main( ){char c;c=getchar( );if(c>=’a’&&c<=’u’)( 1 )else if(c>=’v’&&c<=’z’)( 2 )putchar(c);}24.输入一个字符,如果它是一个大写字母,则把它变成小写,如果是小写,则变成大写,其他字符不变,请在( )填正确内容main ( ){char ch;scanf(“%c”,&ch);if( 1 )ch=ch+32;else if(ch>=’a’&&ch<=’z’)(2)printf(“%c”,ch);}25.以下程序的运行结果是( ) main( ){int a,b,c;int s,w,t;s=w=t=0;a=-1,b=3,c=3;if(c>0)s=a+b;if(a<=0){if(b>0)if(c<=0)w=a-b;}else if(c>0)w=a-b;else t=c;printf(“%d%d%d”,s,w,t);} 26.以下程序的运行结果是( ) main( ){int a,b,c,d,x;a=c=0;b=1;d=20;if(a)d=d-10;else if(! b)if(! c)x=15;else x=25;printf(“%d\n”,d);}27.以下程序的运行结果是( ) #include<stdio.h>main( ){int x,y=1,z;if(y!=0)x=5;printf(“\t%d\n”,x);if(y= =0)x=4;else x=5;printf(“\t%d\n”,x);x=1;if(y<0)if(y>0)x=4;else x=5;printf(“\t%d\n”,x);}28.以下程序的运行结果是( ) #include<stdio.h>main( ){int x,y=-2,z=0;if((z=y)<0)x=4; else if(y= =0)x=5;else x=6;printf(“\t%d\t%d\n”,x,z);if(z=(y= =0))x=5;x=4;printf(“\t%d\t%d\n”,x,z);if(x=z=y)x=4;printf(“\t%d\t%d\n”,x,z);}29.阅读下面程序:main ( ){int s,t,a,b;scanf(“%d,%d”,&a,&b);s=1;t=1;if(a>0)s=s+1;if(a>b)t=s+t;else if(a= =b)t=5;else t=2*s;printf(“s=%d,t=%d”,s,t);}为使输出结果t=4,输入量a和b应满足的条件是( )30.请阅读下面程序:main( ){int s ,t,a,b;scanf(“%d,%d”,&a,&b);s=1;t=1;if(a>0)s=s+1;if(a>b)t=s+t;else if(a= =b)t=5;else t=2*s;printf(“s=%d,t=%d”,s,t);}为使输出结果s=1,t=5,输入量a和b应满足条件是( )31.下面程序根据以下函数关系,对输入的每个x值,计算出y值,在( )填正确内容main( ){int x,y;scanf(“%d,&x);if(1)y=x*(x+2); else if(2)y=2*x;else if(x<=-1)y=x-1;else( 3 );if(y!=-1)printf(“%d”,y);else printf(“error”);}32.下面程序根据以下函数关系,对输入的每个x值,计算出相应的y值.在( ) 填正确内容#include “math.h”main( ){int x,a;float y;scanf(“%d%d”,&x,&a);if( 1 )y=0;else if( 2 )y=sqrt(a*a-x*x);else y=x;printf(“%f”,y);}33.以下程序的功能是计算一元二次方程ax2+bx+c=0的根,在( )填正确内容#include “math.h”main( ){float a,b,c,t,disc,twoa,term1,term2;printf(“enter a,b,c:”);scanf(“%f%f%f”,&a,&b,&c);if( 1 )if( 2 )printf(“no answer due to input error\n”);else printf(“the single root is%f\n”,-c/b);else{disc=b*b-4*a*c;twoa=2*a;terml=-b/twoa;t=abs(disc);term2=sqrt(t)/twoa;if(3)printf(“complex root\n real part=%fimag part=%f\n”, terml,term2);else printf(“real roots\n rootl=%froot2=%f\n”,terml+term2,term1-term2);}} 34.以下程序根据输入的三角形的三边判断是否能组成三角形,若可以则输出它的面积和三角形的类型.在( )填正确内容.#include“math.h”main( ){float a,b,c; float s,area;scanf(“%f %f %f”,&a,&b,&c);if( [1] ){s=(a+b+c)/2;area=sqrt(s*(s-a)*(s-b)*(s-c));printf(“%f”,area);if( [2] )printf(“等边三角形”);else if( [3] )printf(“等腰三角形”);else if((a*a+b*b= =c*c)| |(a*a+c*c= =b*b)| |(b*b+c*c= =a*a) )printf(“直角三角形”);else printf(“一般三角形”);}else printf(“不能组成三角形”);}35. 某邮局对邮寄包裹有如下规定:若包裹的长宽高任一尺寸超过1米或重量超过30千克,不予邮寄;对可以邮寄的包裹每件收手续费0.2元,再加上根据下表按重量wei计算的资料:重量(千克) 收费标准(元/公斤)wei<=10 0.8010<wei<=20 0.7520<wei<=30 0.70请在程序的[ ]内填入正确的内容.main( ){float len,wei,hei,wid,mon,r;scanf(“%f %f %f %f”,&len,&wid,&hei,&wei);if(len>1| |wid>1| |hei>1| |wei>30)[ 1 ];else if(wei<10) r=0.8;else if(wei<=20) r=0.75;else if(wei<=30)[ 2 ];if(r= =-1)printf(“error\n”):else {[ 3 ];printf(“%f”,mon);} }36.以下程序的功能是判断输入的年份是否是闰年.请在[ ]内填入正确的内容.main( ){int y,f;scanf(“%d”,&y);if(y%400= =0) f=1;else if( [1] ) f=1;else [2] ;if(f)printf(“%d is”,y);else printf(“%d is not”,y);printf(“a leap year\n”);}37.有四个数a, b, c, d,要求按从大到小的顺序输出.请在[ ]内填入正确内容main( ){int a,b,c,d,t;scanf(“%d %d %d %d”,&a,&b,&c,&d);if(a<b){t=a;a=b;b=t;}if ([1]){t=c;c=d;d=t;}if(a<c){t=a;a=c;c=t;}if([2]){t=b;b=c;c=t;}if(b<d){t=b;b=d;d=t;}if(c<d){t=c;c=d;d=t;}printf(“%d %d %d %d\n”,a,b,c,d);}38.以下程序的运行结果是__main( ){int a=2,b=3,c;c=a;if(a>b)c=1;else if(a= =b)c=0;else c=-1;printf(“%d\n”,c);}39.编制程序要求输入整数a和b,若a2+b2大于100,则输出a2+b2百位以上数字,否则输出两数之和.40.试编程判断输入的正整数是否既是5又是7的整倍数.若是,则输出yes,否则输出no41.编程序:根据以下函数关系,对输入的每个x值,计算出相应的y值42.编程实现:输入一个整数,判断它能否被3,5,7整除,并输出以下信息之一(1)能同时被3,5,7整除(2)能被其中两个数整除(要指出那两个数)(3)能被其中一个数整除(指出那一个)(4)不能被3,5,7任一个整除1、C2、(1)A (2)C3、B4、C5、D6、C7、B8、C9、C 10、B 11、A 12、B 12、B13、your$3.0yuan/xiaoshi14、2nd class postage is 14p15、selling price(0.30)$ 5.72 (注意:5.72前有2个空格)16、F17、4:05PM18、(1) m=='a' (2) m=='c' (3) m=='b'19、3635.4。
pyif语句练习题Python中的if语句是一种流程控制语句,它提供了一种条件判断的机制。
通过if语句,我们可以根据不同的条件执行不同的代码块。
本文将为你提供一些关于Python中if语句的练习题,帮助你巩固对该语句的理解和运用。
1. 练习题1:比较大小请编写一个程序,接受用户输入的两个数字,然后使用if语句判断两个数字的大小关系,并输出结果。
```pythonnum1 = float(input("请输入第一个数字:"))num2 = float(input("请输入第二个数字:"))if num1 > num2:print("第一个数字大于第二个数字")elif num1 < num2:print("第一个数字小于第二个数字")else:print("两个数字相等")```2. 练习题2:成绩评定请编写一个程序,接受用户输入的一个成绩,然后使用if语句判断该成绩的等级,并输出结果。
假设成绩满分为100分,及格分数为60分,请按照以下标准评定等级:- 90分及以上为优秀- 80分至89分为良好- 70分至79分为中等- 60分至69分为及格- 60分以下为不及格```pythonscore = float(input("请输入成绩:"))if score >= 90:print("优秀")elif score >= 80:print("良好")elif score >= 70:print("中等")elif score >= 60:print("及格")else:print("不及格")```3. 练习题3:奇偶判断请编写一个程序,接受用户输入的一个整数,然后使用if语句判断该整数是奇数还是偶数,并输出结果。
c++if语句选择题1. 下列关于if语句的描述中,正确的是( )。
A. if语句只能用于条件判断B. if语句必须有else子句C. if语句只能有一个条件表达式D. if语句可以嵌套在其他控制语句中2. 下列关于if语句的使用中,错误的是( )。
A. if语句可以在while循环中使用B. if语句可以在for循环中使用C. if语句可以在switch语句中使用D. if语句可以在循环体内部使用3. 下列关于if语句的执行流程中,正确的是( )。
A. 先计算条件表达式的值,再执行if语句块B. 先执行if语句块,再计算条件表达式的值C. 条件表达式的值是true时,才执行if语句块D. 条件表达式的值是false时,才执行if语句块4. 下列关于if语句的语法中,错误的是( )。
A. if (condition) statement;B. if (condition) { statements; }C. if (condition) statement else { statements; }D. if (condition) statement else statement;5. 下列关于if语句的作用域中,正确的是( )。
A. if语句的作用域从if语句开始到if语句结束B. if语句的作用域只包含if语句块中的代码C. if语句的作用域包括if语句块和else语句块中的代码D. if语句的作用域包括整个程序中的代码6. 下列关于if语句的else子句中,错误的是( )。
A. else子句必须与最近的if语句配对使用B. else子句必须放在if语句之后使用C. else子句不能嵌套在其他控制语句中D. else子句可以与if语句分开使用7. 下列关于if语句与switch语句的比较中,正确的是( )。
A. if语句适用于多个条件的情况,而switch语句适用于单个条件的情况B. switch语句的每个case分支相当于一个if-else分支C. switch语句的每个case分支可以包含任意数量的代码,而if-else分支只能包含一个代码块D. switch语句比if-else语句更加高效,因为switch语句使用了跳转表来减少比较次数8. 下列关于嵌套if语句的使用中,错误的是( )。
if条件句练习题一、单项选择1. If I _____ where he lived, I _____ a note to him.A. know, would have sentB. had known, would have sentC. know, would sendD. knew, would have sent2. Mary is ill today. If she _____, she _____ absent from school.A. were not ill; wouldn’t beB. had been ill; wouldn’t have beenC. had been ill; should have beenD. hadn’t been ill; could be3. Alan ___ the party if he had gone to London.A. would have missedB. had missedC. would missD. missed4. If you had enough money, what _____?A. will you buyB. would you buyC. would you have boughtD. will you have bought5. If Mr. Young _____ with justice, he _____ sucha wrong thing.A. were treated; wouldn’t doB. had been treated;wouldn’t have doneC. were treated; wouldn’t have doneD. had been treated; wouldn’t do6. What _____ if there _____ no light during the day?A. will happen; wasB. would happen; isC. happens; wereD. would happen; were7. If I knew you were coming, I ___ you at the airport.A. had metB. metC. would meetD. would have met8. If it _____ not for the fact that you _____ ill now, I would surely punish you.A. is; areB. were; wereC. were; areD. was; were9. Many Chinese movie stars now have given up their Chinese nationality. If I were them, I _____ that.A. shouldn’t doB. didn’t doC. hadn’t doneD. won’t do10. If only I ___ to my parents!A. listenedB. had listenedC. should listenD. would listen11.I ___ you some money, but I hadn’t got any then.A. would lendB. would have lentC. could lendD. may have lent12. If Hey had not pulled his cap low over his brow, he _____ by the police.A. might be recognizedB. might have been recognizedC. would have recognizedD. was to have been recognized13. There is a ring at the door. That _____ be the postman, I suppose.A. willB. wouldC. is going toD. was going to14. Look at the dark clouds—there _____ be a storm.A. willB. must have beenC. is going toD. would15. —Why are you taking the pictures down? —I _____ the wall.A. paintB. have just paintedC. am going to paintD. will have painted16. — Can I stay at home tomorrow? —Yes, you can if it_____.A. will snowB. is going to snowC. snowsD. snowed17. I don’t know if he _____ this afternoon. But if he _____, I will tell you.A. will come; will do;B. comes; will doC. will come; doesD. comes; does18. —I thought I asked you to fix the radio.—Oh, I’m sorry. I _____ it right away.A. am to doB. will doC. was about to doD. am going to do19. The WTO can’t live up to its name _____ it does not include a country that is home to one fifth of mankind.A. as long asB. whetherC. ifD. even though20. Ask him to ring me up if you _____ him.A. seeB. sawC. would seeD. will see21. It’s so late. I don’t think he ______ come.A. wouldB. shouldC. is going toD. shall22. If people _____ polluting the air, animals and plants will die soon.A. don’t stopB. didn’t stopC. shall not stopD. haven’t stopped23. If you _____ an interesting day out, ______ the Science Museum.A. want; visitingB. want; visitC. want to; visitD. wanting; visit24. If the pure water is heated to 100 centigrade degrees, it ______ boil.A. is going toB. willC. wouldD. is to25. Is a dictionary available, _____ so, where?A. ifB. if isC. and ifD. and if is二、翻译句子26. If my brother were here, _____________________________________.27. ___________________________,the crops would be saved.28. __________________________________,you would have met him.29. _________________________________,I would have designed a spaceship.30. Had I a lot of money, ______________________________.if_条件状语从句的时态练习及答案_初中习题集I.单项选择1.If you _____ to the party, you’ll have a great time.a. will gob. wentc. god. going2.It will be a long time ____ peter _____ his work.a. since, has finishedb. after, finishesc. when, will finishd. before, finishes.3. what will father _____ us from Japan?a. takeb. bringc. carryd. make4. Weifang is famous ______ kitesa. forb. toc. ond. with5. I____ her the answer if she ____me.a. can tell, will askb. will tell, will askc. would tell, askd. will tell, asks6. – what are you going to do tomorrow?--we’ll go to the library tomorrow if it ___.a. isn’t rainb. rainc. won’t raind. doesn’t rain7.—Do you know when he will come back tomorrow? --sorry, I don’t know. when he ____ back, I’ll tell you.a. comesb. will comec. comed. may come8. what will you do if you _____ to the old folk’s home visit?a. gob. wentc. goingd. will go9. If I eat ____ food, I’ll be very fat.a. too manyb. many tooc. too muchd. much too10.I’ll give the book to him if he ___ here next sunday.a. will comeb. comesc. is comingd. came11. There ____an english film in our school tomorrow.a. is going to haveb. will havec. is going to bed. has12.Could you tell us where ____?a. will the next olympic games heldb. the next olympic games will be heldc. would the next olympic games be heldd. the next olympic games would be held13. When my mother returned last night,I ____ a book.a. readb. am readingc. was readingd. am going to read14. What ____ you ____ when it began to rain?a. do, dob. were, doingc. are, doingd. did, do15. I’ll wake you up when he ____back.a. willb. is going to comec. comesd. comeII、用所给词的适当形式填空1. If you _______ tired, you ______ to have a rest.2. Where _____ he ______ the film if he ________ time?3. If there ____ fewer trees, there _______ more pollution.4. He _____ more casually if he _______ on weekends.5.If marcia _______ alone, she _______ a pet parrot.6. lana _____ a new dress if the old one ____ out of style.7. The twins _____ if they__________ .8. I______ a bake sale if I____ money for education.9. Peter ____ me a beautiful souvenir if he ____ spain.10.If mr. green _______ I am hard- working, my parents _____ glad.11. I______ to the beach if it________ this week.12. ____they ______ a match if the p.e. teacher_______ busy?13. He _______ a letter to his grandparents if he ______ his report card this week.14. If she ______ up late, she _____ the early bus.15. Peter _________ in English if he _______ the exams in peking university. III. 完成句子1.如果他到的晚了会发生什么事情?What _______________ if he _____________ late?2. 如果努力学习,你就会取得好成绩。
有关if语句的经典例题
1.请输入三个正整数x,y,z。
把这三个正整数按从小到大的顺序输出。
2.输入一个三位正整数,判断其是否是水仙花数。
(水仙花数:一个三位数,各位数字的立方之和等于该数字本身。
)
3.有一个函数:
X x<1
Y= 2*x-1 1=<x<10
3*x-11 x>=10
写一个程序,输入x,输出y。
4.求一个一元二次方程的根。
其中他的系数有键盘输入。
5.编写程序判断某一年是否是闰年。
6.用海伦公式求解三角形的面积。
(海伦公式:)
(*)
(*)
(*c
s
b
s
a
s
s
S-
-
-
=
面积其中:2c
b
a
S +
+
=)
注:本次作业要求把所有程序写在作业纸上,其中所有过程必须要完整(注意头文件、标点等细节问题)。
在下次上课时带上,我要检查!。
班级 学号 姓名1IF 语句练习题一、选择题:1.赋值语句x=x+1的正确含义是(A) 变量x 与x+1的值相等 (B) 将变量x 的值加到x+1中去(C) 将变量x 的值加1后赋值给变量x (D) 变量x 的值为12.VB 语句If i=1 Then j=1,下列说法正确的是 (A)i=1和j=1均为赋值语句 (B)i=1和j=1均为关系表达式(C)i=1为关系表达式,j=1均为赋值语句 (D)i=1为赋值语句,j=1为关系表达式二、填空题:1.有如下VB 程序段:该程序段运行后,变量c 的值为____________。
a = "English" b = "f"c = b + Mid(a, 5, 3)2.有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
t = 130 h = 170b = (h - 100) * 2 If t > b ThenText1.text="超标" ‘ 显示"超标" ElseText1.text="正常" ‘ 显示"正常" End If3.有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
w = 9 a = 90 b = 50If w > 10 Or a * b > 4000 Then Text1.text = "托运" ElseText1.text = "携带" End If4. 有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
a = 10b = 6c = 5If a + b > c And b + c > a And c + a > b Then Text1.text = "YES" ElseText1.text = "NO" End If5. 有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
历年经典真题 If 条件状从句练习1. If there no buying and selling of animals, there no killing in nature. A. is; will he B. will be; will be C. is; is D. will be; is 2.I am waiting for my friend._ , I'll go shopping alone. A. If she comes B. If she won't come C. If she doesn't come D.If she come 3.The students ____ have a sports meeting this weekend if it _____。
A .Won .Won’’t; rains B .will; rains C .Won .Won’’t; will rain D .are going to; is going to rain 4.Work hard ,________ you may catch up with your classmates soon. A.or B.but C.and D.yet 5.We will have no water to drink we don ’t protect the earth. A. until B. before C. though D. if 6.We ’ll plant trees tomorrow, and I don ’t know Tom will come and join us. A. if B. which C. what D. where 7.—Do you know if finished the work? —Not yet. If he , he will give me a call. A. he ’s, will finish B. he ’ll, finishes C. he ’s , finishes D. he ’ll , will finish 8.—Mike wants to know if________a picnic tomorrow. —Yes. But if it________, we ’ll visit the museum instead. A. you have; will rain B. you will have; will rain C. you will have; rains D. will you have; rains 9.---I wonder if you r wife to the party.---If your wife ___, s o will mine. A. will go , go B. will go, goes C.goes, will go D. will go, will go If条件状从句练习题1.If you _____ to the party, you’ll have a great time. A.will go B. went C. go D. Going 2. It will be a long time ____ Peter _____ his work. A.since, has finished B. after, finishes C. when, will finish D. before, finishes. 3.What will father _____ us from Japan? A. take B. bring C. carry D. make 4.Weifang is famous ______ kites. A. for B. to C. on D. with 5.I ____ her the answer if she ____me. A. can tell, will ask B. will tell, will ask C. would tell, ask D. will tell, asks 6.–What are you going to do tomorrow? --We’ll go to the library tomorrow if it ___. A.isn’t rain B. rain C. won’t rain D. doesn’t rain 7.—Do you know when he will come back tomorrow? --Sorry, I don’t know. When he ____ back, I’ll tell you. A. comes B. will come C. come D. may come 8.What will you do if you _____ to the old folk’s home visit? A.go B. went C.going D. will go 9. If I eat ____ food, I’ll be very fat. A.too many B. many too C. too much D. much too 10.I’ll give the book to him if he ___ here next Sunday. A.will come B. comes C. is coming D. came 11.There ____an English film in our school tomorrow. A. is going to have B. will have C. is going to be D. has 12.Could you tell us where ____?A. will the next Olympic Games held B. the next Olympic Games will be held C. would the next Olympic Games be held D. the next Olympic Games would be held a book. 13. When my mother returned last night, I ____ A.read B. am reading C. was reading D. am going to read 14.What ____ you ____ when it began to rain? A.do, do B. were, doing C. are, doing D. did, do 15. I’ll wake you up when he ____back. A. will B. is going to come C. comes D. come 1---5 CDBAD 6---10 DAACB 11---15 CBCBC 答案:A 【解析】考查点:本题考查if 引导的状语从句的时态。
i f语句练习题if语句练习题1.以下不正确的if语句形式是______A)if(x>y&&x!=y);B)if(x= =y)x+=y;C)if(x!=y)scanf(“%d”,&x),else scanf(“%d,&y);D)if(x<y){x++;y++;}2.以下运算符中优先级最低的是(1),优先级最高的是(2)A) ?: B)&& C)+ D)! =3.已知int x=10,y=20,z=30;以下语句执行后x,y,z的值是_____ if(x>y)z=x;x=y;y=z;A)x=10,y=20,z=30 B)x=20,y=30,z=30C)x=20,y=30,z=10 D)x=20,y=30,z=204.以下if语句语法正确的是_____A)if(x>0)printf(“%f”,x)else printf(“%f”,-x);B)if(x>0){x=x+y;printf(“%f’,x);}else printf(“%f”,-x);C)if(x>0){x=x+y;printf(“%f”,x);}else printf(“%f”,-x);D)if(x>0){x=x+y;printf(“%f,x);}else printf(“%f”,-x);5.请阅读以下程序:main( ){int a=5,b=0,c=0;if(a=b+c)printf(“* * *\n”);else printf(“$ $ $\n”);}以上程序______A)有语法错不能通过编译 B)可以通过编译但不能通过连接C)输出* * * D)输出$ $ $6.以下程序的运行结果是______main( ){int m=5;if(m++>5)printf(“%d\n”,m);收集于网络,如有侵权请联系管理员删除else printf(“%d\n”,m--);}A) 4 B) 5 C) 6 D) 77.当a=1,b=3,c=5,d=4时,执行完下面一段程序后x的值是______ if(a<b)if(c<d) x=1;elseif(a<c)if(b<d)x=2;else x=3;else x=6;else x=7;A) 1 b) 2 c) 3 d) 68. 有一个函数关系见下表:下面程序段中能正确表示上面关系的是( )A) y=x+1;if(x>=0)if(x==0)y=x;else y=x-1;b) y=x-1;if(x!=0)if(x>0)y=x+1;else y=x;c) if(x<=0)if(x<0)y=x-1;else y=x;else y=x+1;d)y=x;if(x<=0)if(x<0)y=x-1;else y=x+1;9.以下程序的输出结果是______main( ){int a=100,x=10,y=20,okl=5,ok2=0;if(x<y)if(!ok1)a=1;else收集于网络,如有侵权请联系管理员删除if(ok2) a=10;a=-1;printf(“%d\n”,a);}A 1B 0C -1D 值不确定10.以下程序输出结果是_______main( ){int x=2,y=-1,z=2;if(x<y)if(y<0) z=0;else z+=1;printf(“%d\n”,z);A.3B.2C.1D.011.为避免在嵌套的条件语句if-else中产生二义性,C语言规定:else子句总是与___配对.A.缩排位置相同的ifB.其之前最近的ifC.其之后最近的ifD.同一行上的if12.以下不正确的语句为______A.if(x>y);B.if(x=y)&&(x! =0) x+=y; C,if(x! =y)scanf(“%d”,&x);else scanf(“%d”,&y);D.if(x<y){x++;y++;}12.阅读以下程序#include<stdio.h>main( ){float a, b;scanf(“%f”,&a);if(a<0.0)b=0.0;else if((a<0.5)&&(a!=2.0))b=1.0/(a+2.0);else if(a<10.0)b=1.0/a;else b=10.0;printf(“%f\n”,b);}若运行时输入2.0<回车>,则上面程序的输出结果是_____A)0.000000 B)0.500000 C)1.000000 D)0.25000013.若运行时输入:16<回车>,则以下程序的运行结果是( ) #include<stdio.h>main( ){int year;printf(“Input you year:”);scanf(“%d”,&year);收集于网络,如有侵权请联系管理员删除if(year>=18)printf(“you$4.5yuan/xiaoshi”);else printf(“your$3.0yuan/xiaoshi”);}14.若运行时输入:2<回车>,则以下程序的运行结果是( )#include<stdio.h>main( ){char class;printf(“enter 1for 1stclass post or 2 for 2nd post”); scanf(“%c”,&class);if(class= =’1’) printf(“1st class postage is 19p”); else printf(“2nd class postage is 14p”);}15.若运行时输入:4.4<回车>,则以下程序的运行结果是() #include<stdio.h>main( ){float costprice,sellingprice;printf(“enter cost price $:”);scanf(“%f”,&costprice);if(costprice>=5){sellingprice=costprice+costprice*0.25;printf(“selling price(0.25)$%6.2f”,sellingprice);}else{sellingprice=costprice+costprice*0.30;printf(“selling price(0.30)$%6.2f”,sellingprice);}}16.以下程序的运行结果是( )main( ){ if(2*2= =5<2*2= =4) printf(“T”);else printf(“F”);}17.请阅读以下程序:main( ){int t,h,m;scanf(“%d”,&t);h=(t/100)%12;if(h= =0)h=12;printf(“%d:”,h);m=t%100;if(m<10)printf(“0”);printf(“%d”,m);if(t<1200||t= =2400)printf(“AM”);else printf(“PM”);}收集于网络,如有侵权请联系管理员删除若运行时输入:1605<回车>时,程序的运行结果是( )18.以下程序实现:输入圆的半径r和运行标志m,按照运行标志进行指定计算.请在( )内填入正确的内容.标志运算a 面积c 周长b 二者均计算#define pi 3.14159main( ){char m;float r,c,a;printf(“input mark a c or b&&r\n”);scanf(“%c%f”,&m,&r);if( 1 ){a=pi*r*r;printf(“area is %f”,a);}if( 2 ){c=2*pi*r;printf(“circle is %f”,c);}if( 3 ){a=pi*r*r;c=2*pi*r;printf(“area&&circle are%f%f”,a,c);}} 19.若运行时输入:5999<回车>,则以下程序的运行结果(保留小数后一位)是( )main( ){int x;float y;scanf(“%d”,&x);if(x>=0&&x<=2999)y=18+0.12*x;if(x>=3000&&x<=5999)y=36+0.6*x;if(x>=6000&&x<=10000)y=54+0.3*x;printf(“%6.1f”,y);}20.以下程序实现输出x,y,z三个数中的最大者.请在( )添入正确内容.main( ){int x=4,y=6,z=7;int ( 1 )if( 2 )u=x;else u=y;if( 3 )v=u;else v=z;printf(“v=%d”,v);}21.以下程序实现:输入三个整数,按从大到小的顺序进行输出.请在( )内填入正确内容main( )收集于网络,如有侵权请联系管理员删除{int x,y,z,c;scanf(“%d%d%d”,&x,&y,&z);if( 1 ){c=y;y=z;z=c;}if( 2 ){c=x;x=z;z=c;}if( 3 ){c=x;x=y;y=c;}printf(“%d,%d,%d”,x,y,z);}22.以下程序对输入的两个整数,按从大到小顺序输出.请在( )内填正确内容. main ( ){int x,y,z;scanf(“%d,%d,”,&x,&y);if( 1 ){z=x;(2)}printf(“%d,%d”,x,y);}23.以下程序对输入的一个小写字母,将字母循环后移5个位置后输出.如’a’变成’f’,’w’变成’b’.请在( )填入正确内容#include “stdio.h”main( ) {char c;c=getchar( );if(c>=’a’&&c<=’u’)( 1 )else if(c>=’v’&&c<=’z’)( 2 )putchar(c);}24.输入一个字符,如果它是一个大写字母,则把它变成小写,如果是小写,则变成大写,其他字符不变,请在( )填正确内容main ( ){char ch;scanf(“%c”,&ch);if( 1 )ch=ch+32;else if(ch>=’a’&&ch<=’z’)(2)printf(“%c”,ch);}25.以下程序的运行结果是( )main( ){int a,b,c;int s,w,t;s=w=t=0;a=-1,b=3,c=3;if(c>0)s=a+b;收集于网络,如有侵权请联系管理员删除if(a<=0){if(b>0)if(c<=0)w=a-b;}else if(c>0)w=a-b;else t=c;printf(“%d%d%d”,s,w,t);} 26.以下程序的运行结果是( ) main( ){int a,b,c,d,x;a=c=0;b=1;d=20;if(a)d=d-10;else if(! b)if(! c)x=15;else x=25;printf(“%d\n”,d);}27.以下程序的运行结果是( ) #include<stdio.h>main( ){int x,y=1,z;if(y!=0)x=5;printf(“\t%d\n”,x);if(y= =0)x=4;else x=5;printf(“\t%d\n”,x);x=1;if(y<0)if(y>0)x=4;else x=5;printf(“\t%d\n”,x);}28.以下程序的运行结果是( )#include<stdio.h>main( ){int x,y=-2,z=0;if((z=y)<0)x=4;else if(y= =0)x=5;else x=6;printf(“\t%d\t%d\n”,x,z);if(z=(y= =0))x=5;收集于网络,如有侵权请联系管理员删除x=4;printf(“\t%d\t%d\n”,x,z);if(x=z=y)x=4;printf(“\t%d\t%d\n”,x,z);}29.阅读下面程序:main ( ){int s,t,a,b;scanf(“%d,%d”,&a,&b);s=1;t=1;if(a>0)s=s+1;if(a>b)t=s+t;else if(a= =b)t=5;else t=2*s;printf(“s=%d,t=%d”,s,t);}为使输出结果t=4,输入量a和b应满足的条件是( ) 30.请阅读下面程序:main( ){int s ,t,a,b;scanf(“%d,%d”,&a,&b);s=1;t=1;if(a>0)s=s+1;if(a>b)t=s+t;else if(a= =b)t=5;else t=2*s;printf(“s=%d,t=%d”,s,t);}为使输出结果s=1,t=5,输入量a和b应满足条件是( )31.下面程序根据以下函数关系,对输入的每个x值,计算出y值,在( )填正确内容main( ){int x,y;scanf(“%d,&x);if(1)y=x*(x+2);else if(2)y=2*x;else if(x<=-1)y=x-1;else( 3 );收集于网络,如有侵权请联系管理员删除if(y!=-1)printf(“%d”,y);else printf(“error”);}32.下面程序根据以下函数关系,对输入的每个x值,计算出相应的y值.在( ) 填正确内容#include “math.h”main( ){int x,a;float y;scanf(“%d%d”,&x,&a);if( 1 )y=0;else if( 2 )y=sqrt(a*a-x*x);else y=x;printf(“%f”,y);}33.以下程序的功能是计算一元二次方程ax2+bx+c=0的根,在( )填正确内容#include “math.h”main( ){float a,b,c,t,disc,twoa,term1,term2;printf(“enter a,b,c:”);scanf(“%f%f%f”,&a,&b,&c);if( 1 )if( 2 )printf(“no answer due to input error\n”);else printf(“the single root is%f\n”,-c/b);else{disc=b*b-4*a*c;twoa=2*a;terml=-b/twoa;t=abs(disc);term2=sqrt(t)/twoa;if(3)printf(“complex root\n real part=%fimag part=%f\n”, terml,term2);else printf(“real roots\n rootl=%froot2=%f\n”,terml+term2,term1-term2);}} 34.以下程序根据输入的三角形的三边判断是否能组成三角形,若可以则输出它的面积和三角形的类型.在( )填正确内容.#include“math.h”main( ){float a,b,c;收集于网络,如有侵权请联系管理员删除float s,area;scanf(“%f %f %f”,&a,&b,&c);if( [1] ){s=(a+b+c)/2;area=sqrt(s*(s-a)*(s-b)*(s-c));printf(“%f”,area);if( [2] )printf(“等边三角形”);else if( [3] )printf(“等腰三角形”);else if((a*a+b*b= =c*c)| |(a*a+c*c= =b*b)| |(b*b+c*c= =a*a) )printf(“直角三角形”);else printf(“一般三角形”);}else printf(“不能组成三角形”);}35. 某邮局对邮寄包裹有如下规定:若包裹的长宽高任一尺寸超过1米或重量超过30千克,不予邮寄;对可以邮寄的包裹每件收手续费0.2元,再加上根据下表按重量wei计算的资料:重量(千克) 收费标准(元/公斤) wei<=10 0.8010<wei<=20 0.7520<wei<=30 0.70请在程序的[ ]内填入正确的内容.main( ){float len,wei,hei,wid,mon,r;scanf(“%f %f %f %f”,&len,&wid,&hei,&wei);if(len>1| |wid>1| |hei>1| |wei>30)[ 1 ];else if(wei<10) r=0.8;else if(wei<=20) r=0.75;else if(wei<=30)[ 2 ];if(r= =-1)printf(“error\n”):else {[ 3 ];printf(“%f”,mon);} }36.以下程序的功能是判断输入的年份是否是闰年.请在[ ]内填入正确的内容.main( ){int y,f;scanf(“%d”,&y);if(y%400= =0) f=1;else if( [1] ) f=1;else [2] ;if(f)printf(“%d is”,y);else printf(“%d is not”,y);printf(“a leap year\n”);}37.有四个数a, b, c, d,要求按从大到小的顺序输出.请在[ ]内填入正确内容main( ){int a,b,c,d,t;scanf(“%d %d %d %d”,&a,&b,&c,&d);if(a<b){t=a;a=b;b=t;}if ([1]){t=c;c=d;d=t;}if(a<c){t=a;a=c;c=t;}if([2]){t=b;b=c;c=t;}if(b<d){t=b;b=d;d=t;}if(c<d){t=c;c=d;d=t;}printf(“%d %d %d %d\n”,a,b,c,d);}38.以下程序的运行结果是__main( ){int a=2,b=3,c;c=a;if(a>b)c=1;else if(a= =b)c=0;else c=-1;printf(“%d\n”,c);}39.编制程序要求输入整数a和b,若a2+b2大于100,则输出a2+b2百位以上数字,否则输出两数之和.40.试编程判断输入的正整数是否既是5又是7的整倍数.若是,则输出yes,否则输出no41.编程序:根据以下函数关系,对输入的每个x值,计算出相应的y值42.编程实现:输入一个整数,判断它能否被3,5,7整除,并输出以下信息之一(1)能同时被3,5,7整除(2)能被其中两个数整除(要指出那两个数)(3)能被其中一个数整除(指出那一个)(4)不能被3,5,7任一个整除1、C2、(1)A (2)C3、B4、C5、D6、C7、B8、C9、C 10、B 11、A 12、B 12、B13、your$3.0yuan/xiaoshi14、2nd class postage is 14p15、selling price(0.30)$ 5.72 (注意:5.72前有2个空格)16、F17、4:05PM18、(1) m=='a' (2) m=='c' (3) m=='b'19、3635.4。
六年级英语虚拟语气if 条件句单选题30 题1. If I ____ a fairy, I would make all the children in the world happy.A. amB. wasC. wereD. be答案:C。
解析:在虚拟语气的if条件句中,表示与现在事实相反的假设,be动词要用were,不管主语是第几人称。
A选项am是一般现在时的形式,不符合虚拟语气语法规则;B选项was虽然是be 的过去式,但在虚拟语气中,这种情况下要用were;D选项be是原形,也不符合虚拟语气的用法。
2. If the cat could talk, it ____ tell us many interesting stories.A. willB. wouldC. shallD. should答案:B。
解析:这是一个与现在事实相反的虚拟语气句子。
在这种情况下,if从句用一般过去时(这里是could表示能力,是一般过去时的一种特殊形式),主句要用would + 动原。
A选项will用于一般将来时,不符合虚拟语气;C选项shall一般用于第一人称,表示将来或征求意见等,与虚拟语气无关;D选项should虽然也可用于虚拟语气,但在这里表达的语义和用法不符合,这里需要表示“将会”的意思,所以用would。
3. If Tom ____ more time, he would play football with his friends.A. hasB. hadC. haveD. having答案:B。
解析:这是虚拟语气中与现在事实相反的情况。
if从句中要用一般过去时,主语Tom是第三人称单数,have的过去式是had。
A选项has是一般现在时的第三人称单数形式,不符合虚拟语气规则;C选项have是原形,也不符合;D选项having不是谓语动词形式,不能用于此处。
4. If it ____ sunny tomorrow, we would go for a picnic.A. isB. wasC. wereD. will be答案:C。
1. If he hard, he will get good grades.A. studyB. studiesC. will studyD. studied2. I want to know if Mary to the party tomor row.A. goB. wentC. will goD. goes3. Everyone must dress up. If you , they won’t let you in.A. don’tB. won’tC. can’tD. mustn’t4. Mary will go to Sanya if she a five-day trip.A. haveB. hadC. will haveD. has5. If he comes late, he will miss the train.A. andB. soC. /D. or1.If you ________(feel) tired, you _________ (have) to have a rest.2. Where _____ he ____(see) the film if he _________(have) time?3. If there ____(be) fewer trees, there _______( be) more pollution.4. He ___(dress) more casually if he ___( not work) on weekends.5. If Marcia _______(live) alone, she _______( keep) a pet parrot.6. Lana _____ buy) a new dress if the old one ____(be) out of style.7.The twins _______(fight) if they__________(argue).8. I ______(have) a bake sale if I ____(need) money for education.9. Peter ____( send) me a beautiful souvenir if he ____(tour) Spain.10. If Mr Green _______ (say) I am hard- working, my parents ___( feel) glad.11.I ______(go) to the beach if it________ ( not rain) this week.12. _____they ___( have) a match if the P.E. teacher __(be) busy?13.He ____(write) a letter to his grandparents if he ____(get) his report card this week.14. If she ______(get) up late, she _____ ( not catch) the early bus.。
班级 学号 姓名
1
IF 语句练习题
一、选择题:
1.赋值语句x=x+1的正确含义是
(A) 变量x 与x+1的值相等 (B) 将变量x 的值加到x+1中去
(C) 将变量x 的值加1后赋值给变量x (D) 变量x 的值为1
2.VB 语句If i=1 Then j=1,下列说法正确的是 (A)i=1和j=1均为赋值语句 (B)i=1和j=1均为关系表达式
(C)i=1为关系表达式,j=1均为赋值语句 (D)i=1为赋值语句,j=1为关系表达式
二、填空题:
1.有如下VB 程序段:该程序段运行后,变量c 的值为____________。
a = "English" b = "f"
c = b + Mid(a, 5, 3)
2.有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
t = 130 h = 170
b = (h - 100) * 2 If t > b Then
Text1.text="超标" ‘ 显示"超标" Else
Text1.text="正常" ‘ 显示"正常" End If
3.有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
w = 9 a = 90 b = 50
If w > 10 Or a * b > 4000 Then Text1.text = "托运" Else
Text1.text = "携带" End If
4. 有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
a = 10
b = 6
c = 5
If a + b > c And b + c > a And c + a > b Then Text1.text = "YES" Else
Text1.text = "NO" End If
5. 有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
a = 1.45 : b = 1.67
If a < b Then min = a Else min = b Text1.text = str(min)
6. 有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
x = 32
If x Mod 2 = 0 Then f = True Else f = False Text1.text = x
7. 有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
m = 160
If m <= 100 Then
Text1.text = "不打折"
ElseIf m > 100 And m <= 150 Then Text1.text = "9.5折" Else
Text1.text = "9折" End If
8.有如下VB 程序段:该程序段运行后,在文本框Text1上显示的是____________。
m = 160
If m <= 100 Then
Text1.text = "不打折"
ElseIf m > 100 And m <= 150 Then Text1.text = "9.5折" Else
Text1.text = "9折" End If
班级 学号 姓名
2
三、补充程序段:
1.体质指数(BMI )是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。
其计算公式为:
体质指数(BMI)=体重(Kg)/(身高*身高(M)) 当指数18.5<BMI ≤25为健康
下列VB 程序是用来计算BMI 体质指数的,其中Texw 文本框用于输入体重,Texh 文本框用于输入身高,
Text3文本框用于输出结果,请将程序补充完整 Dim w as single ‘变量w 中存放体重 Dim h as single
‘变量h 中存放身高
‘变量bmi 中存放体质指数
w = Val(Txtw.Text) ‘输入体重 h = Val(Txth.Text) ‘输入身高 BMI =
If Then
Text3.Text = "健康"
Text3.Text = "不健康" End If
2.当体质指数B MI≤18.5为“消瘦”,BMI >25为“肥胖”,18.5<BMI ≤25为正常,如何修改程序 Dim w as single ‘变量w 中存放体重 Dim h as single ‘变量h 中存放身高
h = Val(Txth.Text) w = Val(Txtw.Text)。