Recitation 07 Problems

Recitation 07 Problems - 14:440:127- Introduction to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
14:440:127- Introduction to Computers for Engineers Problems for students to attempt in Recitation 7 1) Write a while loop that continually asks the user to input a number. Each time he/she enters a positive number, you should display that number to the screen. Once the enter a number that’s not positive, the loop should stop, and you should display “Loop Stopped” to the screen. 2) Write a while loop that finds the smallest 8 digit prime number. Then, instead write that loop as a for loop (using the break command). 3) Write a loop to create the following matrix: 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 4) Rewrite the following code using a while loop for k=1:10 x= 50- k^2 if(x<0) break end y= sqrt(x) end 5) Write a while loop that calculates the sum of the first 500 prime numbers. (Notice that this is different than “all of the prime numbers from 1 to 500”) 6) Calculate the total resistance of electrical resistors as follow: First, prompt the user to enter “1” if the resistors are in series, and “2” if they are in parallel. Recall that you calculate the total resistance by summing those in series, or by calculating 1/Rtot = 1/R1 + 1/R2 + . .. for those in parallel.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/11/2010 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

Page1 / 2

Recitation 07 Problems - 14:440:127- Introduction to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online