加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Learning Perl: 2.12. Exercises

发布时间:2020-12-15 20:57:00 所属栏目:大数据 来源:网络整理
导读:? 2.12. Exercises See Appendix A for answers to the following exercises: [5] Write a program that computes the circumference of a circle with a radius of 12.5. Circumference is 2 p times the radius (approximately 2 times 3.141592654). The

Previous Page

Next Page

?

2.12. Exercises

See Appendix A for answers to the following exercises:

  1. [5] Write a program that computes the circumference of a circle with a radius of 12.5. Circumference is 2p times the radius (approximately 2 times 3.141592654). The answer you get should be about 78.5.

  2. [4] Modify the program from the previous exercise to prompt for and accept a radius from the person running the program. So,if users enter 12.5 for the radius,they should get the same number as in the previous exercise.

  3. [4] Modify the program from the previous exercise so,if the user enters a number less than zero,the reported circumference will be zero,rather than negative.

  4. [8] Write a program that prompts for and reads two numbers (on separate lines of input) and prints out the product of the two numbers multiplied together.

  5. [8] Write a program that prompts for and reads a string and a number (on separate lines of input) and prints out the string the number of times indicated by the number on separate lines. (Hint: Use the "x" operator.) If the user enters "fred" and "3," the output should be three lines,each saying "fred". If the user enters "fred" and "299792," there may be a lot of output.

Previous Page

Next Page

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读