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

2024 – Spring I

Student Name: __________________________________


Student ID: _____________________________________

-----------------------------
FINAL TEST (60 minutes)
INTRODUCTION TO PROGRAMMING
Exercise 1(6 points) – use functions
Write C program:
a. Input and output an array has n items (2)
b. Find maximum item, index and value (1)
c. Sort descending array and output (1)
d. Sum of all prime items (2)
e. Does array have all prime items (1)
f. Sort ascending negative items, descending positive items (1)
Ex:
a. Array: 7 5 -3 -1 8 -2
b. Maximum = 8, index = 4
c. Sort: 8 7 5 -1 -2 -3
d. Sum = 12
e. No
f.
Orignal: 7 5 -3 -1 8 -2
Sort: 8 7 -3 -2 5 -1

Exercise 2(2 points)


a. Input an interger number (n) from user. If n<0, reinput until n>=0.
b. Display all perfect numbers <= n
Note:
Students save file: fullname_ex1, fullname_ex2
Create folder name: full name of student
Submit file to folder on google drive

You might also like