Wednesday 12 September 2012

sample questions of c++ 2



                                                                                                Due Date: Nov 15th 2011      
Course: Programming Fundamentals                                                                     Total Marks: 20
                                                                          

These problems are reasonably complex and for most of the students it will take quite a while before they are able to figure out how to solve them. Therefore, I have given more than 10 days to submit this assignment. I am open to help anyone who puts in a serious effort but still unable to develop a program.

Problem 1:
Write a program that prompts the user to input two numbers. The program calculates the average of prime numbers between these numbers and displays it in the format shown below. Use only what we have learned so far in the class.

Hint: 2 is the first prime number. Please make sure that you take care of this in your program.

Sample Output
Enter first number: 1
Enter second number: 20

The average of prime numbers between 1 and 20 is 9.62


Problem 2:
Write a program that prompts the user to input a number. The program determines and prints twin primes till that number in the format shown below. Use only what we have learned so far in the class.

Hint: A pair of prime numbers that differ by 2 (successive odd numbers that are both Prime numbers) is called twin primes. e.g., (3, 5), (5, 7), (11, 13),…

Sample Output
Enter the upper limit: 100

The twin primes from 1 till 100 are:

3, 5
5, 7
11, 13
17, 19
29, 31
41, 43
59, 61
71, 73


Submission Guidelines:
-          No Late Submissions will be entertained
-          Copied Assignments will be marked Zero.

No comments:

Post a Comment