Lab 01
Lab 01
Lab 01
LAB 01
Mỗi Program tạo 1 project riêng có tên theo quy định sau:
Tên Project: <MASV>_ProgramXX
Ví dụ: Sinh viên có masv: CE123456. Tên Project được đặt tên như sau:
CE123456_Program01
CE123456_Program02
CE123456_Program03
CE123456_Program04
CE123456_Program05
…..
Nén tất cả bài làm lại với tên: submit.zip (hoặc submit.rar)
Sau đó submit bài làm (submit.zip hoặc submit.rar) vào mục Labs/Lab01/TênLớp
trên trang:
https://drive.google.com/drive/folders/1X5sMrAAfCOU-
EV5NTZcgxtUJAOtueLne?usp=sharing
Yêu cầu:
- Comment giải thuật đầy đủ
- Format code
- Thông tin phần author
Contents: 08 programs
Program 1 ( 1 marks)
Write the program that allows the user to enter the three edges (a, b and c) of the triangle
then calculates the perimeter and area of the triangle. The program must check that the
three input numbers can make a triangle or not.
Hint: use the function double sqrt (double n) of the math.h library to calculate the square root
of the parameter n.
Example 1: Please enter the first edge of triangle: -9
Please enter the second edge of triangle: 7
Please enter the third edge of triangle: 5
These three numbers must be a positive number!
Example 2: Please enter the first edge of triangle: 4
Please enter the second edge of triangle: -9
Please enter the third edge of triangle: 0
These three numbers must be a positive number!
Example 3: Please enter the first edge of triangle: 1
Please enter the second edge of triangle: 2
Please enter the third edge of triangle: 10 These
three numbers do not make a triangle!
Example 4: Please enter the first edge of triangle: 4
Please enter the second edge of triangle: 5
Please enter the third edge of triangle: 6
The perimeter of the triangle is 15
The area of the triangle is 9.921567
Program 2 ( 1 marks)
Write a program that allows the user to enter the height (h) and the base's radius (r) of the
cylinder and then calculates the total surface area and volume of the cylinder. The
program must check whether the height and the radius is a positive number or not.
Note: The value of π is 3.14159265358979323846 (use the constant M_PI of the math.h
library)
Example 1: Please enter the base's radius of the cylinder: -2
Please enter the height of the cylinder: 0
The height and radius of cylinder must be a positive number!
Example 2: Please enter the base's radius of the cylinder: 1
Please enter the height of the cylinder: 2
The total surface area of the cylinder is 18.8495559215
The volume of the cylinder is 6.2831853072
Program 3 ( 1 marks)
Write a program that allows the user to enter dividend called a and divisor called b. The
program must check whether a is a multiple of b or not.
Program 4 ( 1 marks)
Write a program that allows the user to enter two integers called a and b. The program
must solves linear equation "A*X + B = 0".
Example 1: SOLVING LINEAR EQUATION A*X + B = 0 PROGRAM:
------------------------------------------
------------------------------------------
------------------------------------------
------------------------------------------
Program 5 ( 1 marks)
Write a program that calculates the sum S = 1 - 2 + 3 - 4 + ... + (-1 N+1 * N) and presents
the result as the example below.
Program 6 ( 1 marks)
The sum is S = 1
Program 7 ( 1 marks)
Write a program that calculates the factorial N! = 1 * 2 * 3 * ... * N and presents the
result as the example below
Program 8 ( 3 marks)
Write a program that allows users to enter a numeric array with N elements. The program
performs the functions:
1. The entered array is:
*********************************
1. The entered array is: 19, 28, 3, 482, 12, 5, 41, 156, 300, 184
2. The reverse array is: 184, 300, 156, 41, 5, 12, 482, 3, 28, 19
END