文件名称:c语言练习题
-
所属分类:
- 标签属性:
- 上传时间:2020-05-20
-
文件大小:3.09kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
下载1 (3.09kb)
别用迅雷、360浏览器下载。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
介绍说明--下载内容来自于网络,使用问题请自行百度
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 of 2 other than 0 (ie. it prints out the values of 21, 22, ..., 210). Use a for loop to do the same.
注意 pow 的返回值,与 整数之间如何显示
2.The constant p can be calculated by the infinite series:
p = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 +....
给出通项公式
Write a C program that uses a do/while loop to calculate p 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 p 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. Maximize 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= 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
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.
注意 pow 的返回值,与 整数之间如何显示
2.The constant p can be calculated by the infinite series:
p = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 +....
给出通项公式
Write a C program that uses a do/while loop to calculate p 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 p 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. Maximize 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= 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
(系统自动生成,下载前可以参看下载内容)
下载文件列表
压缩包 : 2019213626-EX05.zip 列表 e5-4.c __MACOSX/._e5-4.c e5-1a.c __MACOSX/._e5-1a.c e5-1b.c __MACOSX/._e5-1b.c e5-2.c __MACOSX/._e5-2.c e5-3.c __MACOSX/._e5-3.c
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.