Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

WORKSHOP 3

Create Folder: StudentCode_StudentName_Workshop3. Eg:


HE19678_NamNT_Workshop3
Complete the exercises from Q1; Q2; …Qn and save to file Q1.C; Q2.C;
….Qn.C corresponds to: (Hoàn thiện các bài tập từ Q1; Q2; …Qn và lưu vào file
Q1.C; Q2.C; ….Qn.C tương ứng:):
Q1: Find the largest prime number less than n, 50<n<100 (n entered from
the keyboard) - Tìm số nguyên tố lớn nhất nhỏ hơn n, 50<n<100 (n nhập từ bàn
phím).
Note: A prime number is a number >=2 and has only 2 divisors, 1 and
itself - Số nguyên tố là số >=2 và chỉ có 2 ước là 1 và chính nó
Print the results as follows:

Note: Save as Q1.C

1
Q2: Print out 5-digit Palindrome numbers (from 3000 - 7000). A
Palindrome number is a number written forward or backward and still only
produces one number. (In ra các số Palindrome có 5 chữ số (từ 3000 - 7000). Số
Palindrome là số viết xuôi hay viết ngược vẫn chỉ cho ra một số.)

Print the results as follows:

Note: Save as Q2.C

Q3: Write a program that inputs a positive integer and outputs the
opposite number (Viết một chương trình nhập vào 1 số nguyên dương, xuất ra
số ngược lại)
For example: Input 123, output 321
Print the results as follows:

Note: Save as Q3.C

2
Q4: Write a Menu program using switch ... case to represent the image:
Print the results as follows:

Note: Save as Q4.C

3
Q5: Write a program to input 3 float real number values, then find the smallest
value among those 3 numbers (Viết chương trình nhập vào 3 giá trị kiểu số thực
float, sau đó tìm giá trị nhỏ nhất trong 3 số đó):
- Use pointer to write the input function as follows: void input(float *a,
float *b, float *c);
- Write a compare function to find the smallest value as follows: float
compare(float a, float b, float c);
Call the above functions and display the following information:

Note: Save as Q5.C

4
Q6: Enter M, N from the keyboard. Print out the rectangle as follows
(Nhập M, N từ bàn phím. In ra hình chữ nhật như sau):

Note: Save as Q6.C

You might also like