tuesday_programming - ECE 190 Midterm Exam 1 Spring 2011...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 190 Midterm Exam 1 Spring 2011 Tuesday, February 15, 2011 In this assignment, you will need to write a program to count the number of primes less than n . A prime is a number that is not a multiple of any positive number other than 1 and itself. 1 is not a prime by definition. 2 is a prime because it is not divisible by any numbers other than 1 and itself; 4 is not a prime because it is divisible by 2, and so on. First, your program should ask the user " What is n? ". The user will reply with a positive integer n . You will compute the number of primes less than n and will provide the answer in the format " There are m primes less than n . " followed by a newline where m is the actual number of primes found and n is the number entered by the user. Sample run for your program when n is 191 should look like this: What is n? 191 There are 42 primes less than 191 You may NOT use any functions from math.h . To aid you in debugging or testing, here is a complete list of all 25 prime numbers between 1 and 100:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online