2021年3月30日 星期二

C++ Lesson 4 Assignment

 

學習目標:

1.      複習所有曾學習的C++指令,包括cin, cout, if..else, for loop及變量的設定

2.      應用以上的指令。

 

參考文件: 所需語法

 

Assignment 4-1

Calculate the area of a square

-          Let the user enter the length and then output the area of the square.

The output is as follow:



 

Assignment 4-2

Calculate the area of a circle

-          Let the user enter the radius and then output the area of the circle



 

Assignment 4-3

To judge whether a mark means passed or failed.

-          Let the user enter a mark. If the mark is larger than 60, output “passed. If not, output “failed”.





 

Assignment 4-4

To judge whether a number can be divided by 3.

-          Let the user enter a number, if the number can be divided by 3, output “ this number can be divided by 3. If not, output “this number cannot be divided by 3”.



Assignment 4-5

Enter a number and then output the same number of “*” in one line.



Assignment 4-6

Calculate the sum of all the numbers between two numbers.

-          Enter two number, output the sum of the all the numbers between these two numbers.


Assignment 4-7

Output a square made of “*”

-          Enter a number, and output a square with the same number of “* at each side.



Assignment 4-8

Output a right-angled triangle

-          Enter the base length of a right-angled triangle and then output the right-angled triangle



Assignment 4-9

Use loop function to output a 9x9 Table


Assignment 4-10

To judge a number whether it is a prime number

-          Enter a number and then judge whether it is a prime number.



Assignment 4-11

Output all the prime numbers between 1 to 100


Assignment 4-12
Let the user to enter a number, and then output all the prime numbers between 1 and the entered number.




沒有留言:

張貼留言

如何於C++產生亂數?

 如 何於 C++ 產生亂數 ?   以下是一個例子,輸出一個由 0-4 的亂數。留意,行號 2,3,8,9,10 及 11 是需要的。 備註 : 如要輸出 0-9 的話,把行 11 的 rand()%5 改成 rand()%10 便可以。   -----...