微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Learning Perl: 2.12. Exercises

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐