ImageVerifierCode 换一换
格式:DOCX , 页数:8 ,大小:18.47KB ,
资源ID:9538206      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9538206.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(c语言编程全部练习.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

c语言编程全部练习.docx

1、c语言编程全部练习命名 文件和名相同 压缩包文件无所谓 3414_E01.zip在下周二上课前交Exercise 1: Programming Environment and Basic Input/Output1.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

2、 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 c

3、onversion specifier (i.e. no %).(c)Using one “printf” statement with four conversion specifiers3(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 minute

4、s?Exercise 2: Data Types and Arithmetic Operations1. 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).2Write a program that reads in the radius of a circle and prints

5、the circles diameter, circumference and area. Use the value 3.14159 for “ ”.3Write 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

6、 interest payment. Your program should be able to reproduce the following sample run:Interest calculation program.Starting balance? 6000Annual interest rate percentage? 4.25Balance after one year: 6255.00Exercise 3: Selection structure1Write a C program that accepts a students numerical grade, conve

7、rts 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).2Write a program that asks the user to enter an integer number, then tells the user whether it is an odd or even number. 3Write a program that reads in thr

8、ee integers and then determines and prints the largest in the group.Exercise 4: switch statement and simple “while” repetition statement1. 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

9、day should be followed by an appropriate suffix, st, nd, rd or th. Use at least one switch statement.2Write 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

10、 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 salespersons sales for the previous week, and print out their salary. Process one persons figures at

11、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): -1Optional:两重的while4. A mail order company sells five different products who

12、se retail prices are shown in the following table: Product Number Retail Price (in pounds) 1 2.98 2 4.50 3 9.98 4 4.49 5 6.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

13、 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).Exercise 5: for and do while” repetition statements 1. Write a program which uses a do/while loop to print out the first 10 powers

14、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/3 + 4/5 - 4/7 + 4/9 - 4/11 +. Write a C program that uses a do/while loop to calculate using the series. The program should ask the user

15、 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.Nested repetition 3. Write a program that prints the following diamond shape. You may use printf statements that print either a single asterisk (*) or a single blank. Max

16、imize your use of repetition (with nested for statements) and minimize the number of printf statements.*4. Write a program to print a table as follows:1*1= 12*1= 2 2*2= 43*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=81Exercise 6: Simple Functions 1.Write a C progra

17、m 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 o

18、f 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.0

19、0. 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 t

20、he 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.Exercise 7: More Functions1. Write a program

21、 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

22、 function even and use it 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

23、 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

24、, 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 whe

25、n exponent is 1 since : base1 = base.)Exercise 8: Arrays1.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 m

26、aximum and minimum values held in: (a) each row (2 rows) (b) the whole array3Use 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. Pre

27、pare for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.Exercise 9: More Arrays1.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 tow

28、ns 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. (

29、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)Exercise 10: Pointers1. Write a program that reads 5 integers into an array, and then uses

30、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 acc

31、ess the members of the array.3. Write a program that use a SINGLE FUNCTION (用一个函数)to find and return simultaneously both the lowest and highest values in an array of type int. Suppose the size of the array is 6. Exercise 11: Files1. Write a program that enters the name and the annual salary of 5 employees from the keyboard, calculates the monthly salary of each employee assuming that tax is deducted at a flat rate of 20%. The program prints the name, the annual salary and the monthly payment (net) of each employee in a file. The program adds an employees number to each employee before prin

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1