已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
精品文档 1欢迎下载 命名 文件和邮件名相同 压缩包内文件无所谓 3414 E01 zip 在下周二上课前交 ExerciseExercise 1 1 ProgrammingProgramming EnvironmentEnvironment andand BasicBasic Input OutputInput Output 1 Write a program that prints This is my first program on the screen a Save this program onto your own disk with the name of e2 1a b Run this program without opening Turbo C c Modify this program to print This is my second program then save it as e2 1b Please do not overwrite the first program 2 Write a program that prints the number 1 to 4 on the same line Write the program using the following methods a Using four printf statements b Using one printf statement with no conversion specifier i e no c Using one printf statement with four conversion specifiers 3 a Write a program that calculates and displays the number of minutes in 15 days b Write a program that calculates and displays how many hours 180 minutes equal to c Optional How about 174 minutes ExerciseExercise 2 2 DataData TypesTypes andand ArithmeticArithmetic OperationsOperations 1 You purchase a laptop computer for 889 The sales tax rate is 6 percent Write and execute a C program that calculates and displays the total purchase price net price sales tax 2 Write a program that reads in the radius of a circle and prints 精品文档 2欢迎下载 the circle s diameter circumference and area Use the value 3 14159 for 3 Write a program that reads in two numbers an account balance and an annual interest rate expressed as a percentage Your program should then display the new balance after a year There are no deposits or withdraws just the interest payment Your program should be able to reproduce the following sample run Interest calculation program Starting balance 6000 Annual interest rate percentage 4 25 Balance after one year 6255 00 ExerciseExercise 3 3 SelectionSelection structurestructure 1 Write a C program that accepts a student s numerical grade converts the numerical grade to Passed grade is between 60 100 Failed grade is between 0 59 or Error grade is less than 0 or greater than 100 2 Write a program that asks the user to enter an integer number then tells the user whether it is an odd or even number 3 Write a program that reads in three integers and then determines and prints the largest in the group ExerciseExercise 4 4 switchswitch statementstatement andand simplesimple whilewhile repetitionrepetition statementstatement 1 Write a program that reads three integers an abbreviated date for example 26 12 94 and that will print the date in full for example 26th December 1994 The day should be followed by an appropriate suffix st nd rd or th Use at least one switch statement 精品文档 3欢迎下载 2 Write a C program that uses a while loop to calculate and print the sum of the even integers from 2 to 30 3 A large chemical company pays its sales staff on a commission basis They receive 200 per week plus 9 of their gross sales for that week For example someone who sells 5000 of chemicals in one week will earn 200 plus 9 of 5000 a total of 650 Develop a C program that will input each salesperson s sales for the previous week and print out their salary Process one person s figures at a time Enter sales in pounds 1 to end 5000 00 Salary is 650 00 Enter sales in pounds 1 to end 00 00 Salary is 200 00 Enter sales in pounds 1 to end 1088 89 Salary is 298 00 Enter sales in pounds 1 to end 1 Optional 两重的 while 4 A mail order company sells five different products whose retail prices are shown in the following table Product NumberRetail Price in pounds 12 98 24 50 39 98 44 49 56 87 Write a C program that reads in a series of pairs of numbers as follows 1 Product number 2 Quantity sold for one day Your program should use a switch statement to help determine the retail price for each product and should use a sentinel controlled loop to calculate the total retail value of all products sold in a given week 7days ExerciseExercise 5 5 forfor andand dodo whilewhile repetitionrepetition statementsstatements 精品文档 4欢迎下载 1 Write a program which uses a do while loop to print out the first 10 powers of 2 other than 0 ie it prints out the values of 21 22 210 Use a for loop to do the same 2 The constant can be calculated by the infinite series 4 4 4 34 3 4 54 5 4 74 7 4 94 9 4 114 11 Write a C program that uses a do while loop to calculate using the series The program should ask the user how many terms in the series should be used Thus if the user enters 3 then the program should calculate as being 4 4 3 4 5 NestedNested repetitionrepetition 3 Write a program that prints the following diamond shape You may use printfprintf statements that print either a single asterisk or a single blank Maximize your use of repetition with nested forfor statements and minimize the number of printfprintf statements 4 Write a program to print a table as follows 1 1 1 2 1 2 2 2 4 3 1 3 3 2 6 3 3 9 9 1 9 9 2 18 9 3 27 9 4 36 9 5 45 9 6 54 9 7 63 9 8 72 9 9 81 精品文档 5欢迎下载 ExerciseExercise 6 6 SimpleSimple FunctionsFunctions 1 Write a C program that reads several numbers and uses the function round to nearest to round each of these numbers to the nearest integer The program should print both the original number and the rounded number 2 Write a program that reads three pairs of numbers and adds the larger of the first pair the larger of the second pair and the larger of the third pair Use a function to return the larger of each pair 3 A car park charges a 2 00 minimum fee to park for up to 3 hours and an additional 0 50 for each hour or part hour in excess of three hours The maximum charge for any given 24 hour period is 10 00 Assume that no car parks for more than 24 hours at a time Write a C program that will calculate and print the parking charges for each of 3 customers who parked their car in the car park yesterday The program should accept as input the number of hours that each customer has parked and output the results in a neat tabular form along with the total receipts from the three customers Car Hours Charge 1 1 5 2 00 2 4 0 2 50 3 24 0 10 00 TOTAL 29 5 14 50 The program should use the function calculate charges to determine the charge for each customer ExerciseExercise 7 7 MoreMore FunctionsFunctions 1 Write a program that uses sentinel controlled repetition to take an integer as input and passes it to a function even which uses the modulus operator to determine if the integer is even The function even should return 1 if the integer is even and 0 if it is not The program should take the value returned by the function even and use it 精品文档 6欢迎下载 to print out a message announcing whether or not the integer was even 2 Write a C program that uses the function integerPower1 base exponent to return the value of baseexponent so that for example integerPower1 3 4 gives the value 3 3 3 3 Assume that exponent is a positive non zero integer and base is an integer The function should use a for loop and make no calls to any math library functions 3 Write a C program that uses the recursive function integerPower2 base exponent to return the value of baseexponent so that for example integerPower2 3 4 gives the value 3 3 3 3 Assume that exponent is a positive non zero integer and base is an integer The function should make no calls to any math library functions Hint the recursive step will use the relationship baseexponent base baseexponent 1 and the base case will be when exponent is 1 since base1 base ExerciseExercise 8 8 ArraysArrays 1 Write a program that reads ten numbers supplied by the user into a single subscripted array and then prints out the average of them 2 Write a program that reads ten numbers supplied by the user into a 2 by 5 array and then prints out the maximum and minimum values held in a each row 2 rows b the whole array 3 Use a single subscripted array to solve the following problem Read in 20 numbers each of which is between 10 and 100 inclusive As each number is read print it only if it is not a duplicate of a number already read 精品文档 7欢迎下载 Prepare for the worst case in which all 20 numbers are different Use the smallest possible array to solve this problem ExerciseExercise 9 9 MoreMore ArraysArrays 1 Write a program that enters 5 names of towns and their respective distance an integer from London in miles The program will print of the names of the towns that are less than 100 miles from London Use arrays and character strings to implement your program 2 Write a program that prompts the user to type in four character strings places these in an array of strings and then prints out e g I am Peter Pan i The four strings in reverse order e g Pan Peter am I ii The four strings in the original order but with each string backwards e g I ma reteP naP iii The four strings in reverse order with each string backwards e g naP reteP ma I ExerciseExercise 10 10 PointersPointers 1 Write a program that reads 5 integers into an array and then uses four different methods of accessing the members of an array to print them out in reverse order 2 Write a program that reads 8 floats into an array and then prints out the second fourth sixth and eighth members of the array and the sum of the first third fifth and seventh using pointers to access the members of the array 3 Write a program that use a SINGLE FUNCTION 用一个函数 to find and retu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 体检中心医疗纠纷预防与处理工作手册
- 纳米胶体软磁性材料典型计量特性测量规范
- 工矿危险化学品安全管理手册
- 食品安全与操作流程手册
- 起重机吊装作业风险辨识与防控措施手册
- 项目书风险评估与应对策略编写手册
- 船舶安全管理与应急处理手册
- 2026年保险合同纠纷代理服务合同二篇
- 2018新版gmp培训试题及答案
- 2025年海南省三亚市高职单招职业技能考试模拟试卷带答案详解(综合题)
- TCPCIF-《化学品自动化立体仓库设计规范》
- 《微针治疗操作规范》团体标准(征求意见稿)
- 危险药品运输制度规范
- 2025年湖南事业单位招聘考试(计算机)细选练习试题及答案
- 2026江西吉安市吉水县城控人力资源服务有限公司招聘劳务外包1人备考题库(一)有答案详解
- 加油站改造工程安全文明施工方案
- 数控车床装配流程及工艺标准说明
- 浙江省六校联盟2024-2025学年高二上学期期中联考英语试题英语答案
- 2025年河北机关事业单位工人技能等级考试(公路养护工-技师)试题及答案
- 2025版《煤矿安全规程》解读
- 2025译林版新教材初中英语八年级上册单词表(复习必背)
评论
0/150
提交评论