Computer Programming (I)

Lab Test for Programming Assignment 3

Nov 22, 2006

 

1.         Write a function called my_pow(double x, int i) that computes the ith power of x (xi次方)Use my_pow to print the following table:

1

2

3

5

7

2

4

9

25

49

3

8

27

125

343

.

 

 

 

 

.

 

 

 

 

10

 

 

 

 

 

2.         Write a function called isPrime(int i) that return true if i is a prime number(質數), false otherwise. Use this function to compute and print out all prime numbers between 500 and 1000.

 

考題中文翻譯:

1.                                                       寫一叫my_pow(double x, int i)function計算xi次方。用my_pow印出下表:

2.                                                       寫一叫isPrime(int i)function回傳i是否為一質數。用isPrime印出5001000中所有的質數。