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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

C语言全部题目及答案.docx

1、C语言全部题目及答案C语言全部题目及答案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 program to print “This

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

3、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 minutes?ANSWERS:#includein

4、t main()printf(This is my first program!);return 0;#includeint main()printf(This is my second program!);return 0;#includeint main()printf(1);printf(2);printf(3);printf(4);return 0;#includeint main()printf(1234);return 0;#includeint main()printf(%d%d%d%d,1,2,3,4);return 0;#includeint main()float days

5、,minutes;days = 15;minutes = days * 24 * 60;printf(The number of minutes in 15 days are %fn, minutes);return 0;#includeint main()float minutes,hours;minutes = 180;hours = minutes / 60;printf(180 minutes equal to %f hoursn, hours);return 0;#includeint main()float minutes,hours;minutes = 174;hours = m

6、inutes / 60;printf(174 minutes equal to %f hoursn, hours);return 0;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).

7、2Write a program that reads in the radius of a circle and prints 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 b

8、alance 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? 6000Annual interest rate percentage? 4.25Balance after one year: 6255ANSWER:#includeint main()float net_

9、price,sales_tax,total;net_price = 889;sales_tax = net_price * 0.06;total = net_price + sales_tax;printf(The total purchase price is %g, total);return 0;#includeint main()printf(Please input a number as radius:n);float radius,diameter,circumference,area;scanf(%f,&radius);printf(The diameter is %gn,di

10、ameter = radius * 2);printf(The circumference is %gn,circumference = radius * 2 * 3.14159);printf(The area is %gn, area = radius * radius * 3.14159);return 0;#includeint main()float SB,percentage,NB;printf(Interest calculation programnnPlease enter the Starting Balance:);scanf(%f,&SB);printf(Please

11、enter the Annual interest rate percentage:);scanf(%f,&percentage);NB = SB * percentage / 100 + SB;printf(nThe Balance after one year is:%g,NB);return 0;Exercise 3: Selection structure1 Write a C program that accepts a students numerical grade, converts the numerical grade to Passed (grade is between

12、 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 la

13、rgest in the group.ANSWER:#includeint main() int grade; printf(Please enter the grade:); scanf(%d,&grade); if (grade = 60 & grade = 0 & grade 60) printf(Failed.); else printf(Error.); return 0;#includeint main() int a,b,c; printf(Please enter 3 integer numbersn); printf(Then Ill tell you which is th

14、e largestn); scanf(%d%d%d,&a,&b,&c); if (a b & a c) printf(%d is the largest,a); else if (b a & b c) printf(%d is the largest,b); else if (c a & c b) printf(%d is the largest,c); else printf(Theyre equal); return 0;#include#includeint main() int a; printf(Please enter an integer numbern); printf(Then Ill tell you whether its an odd or even number); scanf(%d,&a); if (a%2 = 0) printf(%d is an even number,a); else

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

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