0% found this document useful (0 votes)
40 views4 pages

C/C++ Programming Lab 02

The document provides instructions for 4 C/C++ programming tasks: 1) Write a program to calculate factorials for odd and even integers differently, 2) Write a program to represent an integer as the product of prime numbers, 3) Sort the first half of an even-length array in increasing order and the second half in decreasing order, 4) Write a program to print a specified "x pattern" number.

Uploaded by

Sơn Xuân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

C/C++ Programming Lab 02

The document provides instructions for 4 C/C++ programming tasks: 1) Write a program to calculate factorials for odd and even integers differently, 2) Write a program to represent an integer as the product of prime numbers, 3) Sort the first half of an even-length array in increasing order and the second half in decreasing order, 4) Write a program to print a specified "x pattern" number.

Uploaded by

Sơn Xuân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

C/C++ Programming

Lab 02
1. Write a program to calculate the factorial with given integer n, which satisfies the
following:
if n is odd, factorial = 1 * 3 * 5 * … * n
if n is even, factorial = 2 * 4 * 6 *… *n

2. Write a program to represent a given integer as product of prime numbers


Example: 24 = 2*2*2*3

3. Input an array of n integers, n is even. Sort the first half in increasing order and second
half in decreasing order.
4. Write a program to print x pattern number. Look at the following example and work your
way to the solution:
Input: n = 5
Output:
ANSWER PART
Name-ID Tasks
Nguyễn Xuân Sơn – ITITIU20295 Q1 - Q2
Khưu Khôn Lâm – ITITIU18303 Q3 – Q4

Question 1:

Question 2:
Question 3:

Question 4:

You might also like