Assignment_PRF192
Assignment_PRF192
PRF192
Area S = q(q a )(q b)(q c) with q = (a+b+c) /2 (q: is half the circumference).
In which: a,b,c, are the 3 sides of the triangle (check that a,b,c must meet the conditions
to form 3 sides of the triangle).
19. Enter 3 numbers a,b,c. Check to see if a,b,c form 3 sides of a triangle? If yes, please tell
us what kind of triangle it is (regular, right, isosceles, equilateral, isosceles). Calculate
the perimeter and area of the triangle.
20. Output to the screen numbers that are divisors of n (eg: n = 50 includes divisors:
1,2,5,10,25)
21. Output to the screen the sum of numbers that are divisors of n.
For example: With n = 50, the total output is s = 1+2+5+10 +25 = 18
22. Count the number of “divisors” of the positive integer n
23. List all the “odd divisors” of the positive integer n
24. Decompose n into a product of prime factors.
For example: With n = 100, output 100 = 2*2*5*5
ARRAY
Write a program using functions to solve the following problems:
25. Find the value in the array of real numbers "farthest from value x".
EX: 24 45 23 13 43 -12
Value x = 15
Distance from x = 15 to other elements in the array is:
9 30 8 2 28 27
Value in the array farthest from value x is 45
26. Given a one-dimensional array of real numbers, find the segment [a,b] such that this
segment contains all the values in the array (TimDoan).
27. Find the first value in a one-dimensional array of integers whose first digit is an odd
digit. If such a value does not exist in the array, the function will return the value 0.
28. (*) Given a one-dimensional array of integers. Write a function to find the digit that
appears the least in the array (timchuso).
29. Count the number of values ending in 5 in the array of integers (demtancung).
30. List the values that appear in the sequence more than once (lietke). Note: each value is
listed once.
31. Let's check whether the array of integers exists or not. If yes return 1, otherwise return
0.
32. Let's add an element with value x to the array at position k (themvitri).
33. Delete all negative numbers in the array of real numbers (xoaam).
34. Lists increasing sub-sequences in the array (lietkecontang).
35. Given a one-dimensional array of integers a. Let's create array b from array a, so that
array b only contains odd values.
36. Write a function to count the number of prime numbers in a matrix of integers.
37. Calculate the average of positive numbers in a matrix of real numbers.
38. Check whether a matrix row is increasing or not.
39. List rows containing prime numbers in the matrix of integers.
40. Calculate the sum of the elements on the sub-diagonal of a square matrix.
41. Count the number of positive values on the main diagonal in a square matrix of real
numbers.
42. Check whether the matrix is symmetric about the main diagonal or not.
STRING
43. Write a program to calculate the length of a given string without using the built-in
strlen() function.
44. Write a program to reverse a given string.
45. Write a program to concatenate two strings without using the built-in strcat() function.
46. String Comparison: Write a program to compare two strings without using the built-in
strcmp() function.
47. String Copy: Write a program to copy one string to another without using the built-in
strcpy() function.
48. String Palindrome Check: Write a program to check if a given string is a palindrome
or not.
49. String Tokenization: Write a program to tokenize a sentence into words and print each
word separately.
50. Character Frequency Count: Write a program to count the frequency of each character
in a given string.
51. Character Conversion: Write a program to convert all lowercase characters in a string
to uppercase characters.
52. String Search: Write a program to search for a substring within a given string and print
the position of its occurrence.·