AI Generated exam
Exercise 1:
Write a function that takes an integer N as a parameter and returns the sum of all even numbers from 1 to N. Use a for or while loop to go through the numbers and check if they are even. If so, add them to the sum.
Exercise 2:
Write a function that takes an integer N as a parameter and displays a triangle of size N. Use nested loops to manage the display of rows and columns.
Exercise 3:
Write a function that takes an array of integers array[] and an integer size (the size of the array). The function must return the maximum value of the array. Use a loop to go through all the elements in the array.
Exercise 4:
Write a function that takes two 3x3 matrices (two two-dimensional arrays) as parameters, and fills a third array resultat with the sum of the two matrices. Use nested loops to cycle through each element of the matrix.
Exercise 5:
Write a function that takes a string (char array) and inverts its contents. Use a loop to traverse the string, and a swap algorithm to invert the characters.
Exercise 6:
Write a function that takes a string of characters as a parameter and returns the number of vowels (a, e, i, o, u) it contains. Loop through each character in the string and check if it's a vowel.