# PREE HW#3 - HW#3 Tzu-Ying Hsu(9083 1-1/usr/local/bin/perl-W...

• Notes
• 4

This preview shows pages 1–3. Sign up to view the full content.

HW#3 Tzu-Ying Hsu(9083) 1-1. #!/usr/local/bin/perl -W # This program shows the use of mathematicaal operators. \$a = 13; \$b = 4; \$c = 5; \$res1 = \$a + 4; \$res2 = \$a - 4; \$res3 = \$a * 4; \$res4 = int(\$a / \$b); \$res5 = \$a % \$b; \$res6 = \$c ** 2; print ("\$a + 4 = \$res1\n"); print ("\$a - 4 = \$res2\n"); print ("\$a * 4 = \$res3\n"); print ("\$a / \$b = \$res4\n"); print ("\$a % \$b = \$res5\n"); print ("\$c ** 2 = \$res6\n"); #end of pgm 1-2. #!/usr/local/bin/perl -w # This program shows the use of mathematical operators \$a = 13.7; \$b = 4.4; \$c = 5.2; \$res1 = \$a + 4; \$res2 = \$a - 4; \$res3 = \$a * 4; \$res4 = \$a / \$b; \$res5 = \$a % \$b; \$res6 = \$c ** 2; print ("\$a + 4 is \$res1\n"); print ("\$a - 4 is \$res2\n"); print ("\$a * 4 is \$res3\n"); print ("\$a / \$b is \$res4\n"); print ("\$a % \$b is \$res5\n"); print ("\$c ** 2 is \$res6\n"); # End of the program 1-3. #!/usr/local/bin/perl -w #This program shows the average of four numbers.

This preview has intentionally blurred sections. Sign up to view the full version.

print ("Enter the first number:23 \n"); \$num1 = 23; print ("Enter the second number:56 \n"); \$num2 = 56; print ("Enter the third number:34 \n"); \$num3 = 34; print ("Enter the four number:12 \n"); \$num4 = 12; \$ave = (\$num1+\$num2+\$num3+\$num4) / 4; print ("The average of four numbers is \$ave \n"); #End of the program 1-4. #!/usr/local/bin/perl -w # This program displays the first digit and the rest of the digits is a number.
This is the end of the preview. Sign up to access the rest of the document.
• Spring '10
• alex
• Randomness, random number, Statistical randomness, #End

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern