Programming
Arrays
1. Write a program, which will read in integer numbers into a 10-element vector. After this calculate the average of the values. Finally determine the largest element of this vector. Print
these results.
2. Write a program, which will read in integer numbers into a 10-element vector. After this determine the number of positive, negative and zero elements in the vector. Print the results.
3. Write a program, which will read in integer numbers into a 10-element vector. After this read in another integer number and store it in a separate variable. The program must determine,
whether the last read number is equal to the product of any pair of numbers in the vector.
4. Write a program, which will read in real numbers into two 10-element vectors. The program must calculate the scalar product of these two vectors and print the results.
5. Write a program, which fills a 5x5 integer matrix. The user must specify the values in the matrix. After this, determine the largest and smallest elements in every row of the matrix. Print all
results.
6. Write a program, which fills a 5x5 integer matrix. The user must specify the values in the matrix. After this, lets determine the index of the column, which has the fewest number of positive
integer numbers. Print the column index out.
7. Write a program, which fills a 5x5 matrix with real numbers. The user must specify the values in the matrix. After this, determine the sum of the elements of rows, one-by-one, and the sum of
the elements of columns as well. Print all results.
8. Write a program, which fills a 5x5 matrix with real numbers. The user must specify the values in the matrix. After this, the program must determine the maximal and minimal values of the main
diagonal of the matrix.
9. Write a program, which fills a 5x5 matrix with real numbers. The user must specify the values in the matrix. After this determine the index of the column, which has the largest element in the
whole matrix. Print the result.
10. Write a program, which fills a 5x5 matrix with real numbers. The user must specify the values in the matrix. After this, add together the elements above the main diagonal and write this value
into the main diagonal. Print the matrix out.
11. Write a program, which fills a 5x5 matrix with real numbers. The user must specify the values in the matrix. After this, add together the elements below the main diagonal and write this value
into the main diagonal. Print the matrix out.
12. Write a program, which fills a 5x5 matrix with real numbers. The user must specify the values in the matrix. After this, read in two integer numbers between 0 and 4. The program must
exchange the specified rows in the matrix. Print the matrix out.
13. Write a program, which fills a 5x5 matrix with real numbers. The user must specify the values in the matrix. After this, read in two integer numbers between 0 and 4. The program must
exchange the specified columns in the matrix. Print the matrix out.
14. Write a program, which will read in integer numbers into a 10-element vector. Also define a 2x5 integer matrix. The program must copy the values from the vector into the matrix. First fill up the
rows. Print out the matrix.
Strings
1. Write a program, which reads in a string. The string can have maximum 20 characters. After this the programu must count the number of letter ’e’ in the string. Print the result.
2. Write a program, which reads in a string. The string can have maximum 70 characters. Count how many numbers (’0’, ’1’, ’2’, …, ’9’) are in the string. Print the results.
3. Write a program, which reads in 5 pieces of 10-character long family names. The program should also read in 3 pieces of 10-character long first names. Print out all combinations of possible
names.
4. Write a program, which reads in a string. The string can have maximum 70 characters. After this, replace every non-letter characters to a space. Print the result.
5. Write a program, which reads in a string. The string can have maximum 70 characters. After this, determin how many letters and non-letters are in the string. Print out the result.
6. Write a program, which reads in two strings. Determine whether the two strings are anagramma. They are anagramma, if they have the same number of same type of characters.
7. Write a program, which reads in a string. The string can have maximum 70 characters. After this, the program reprint thr string in a way, that after every vowel print a letter ’v’ and the vowel
again. For example: apple � avappleve
8. Write a program, which reads in a string. The string can have maximum 10 characters. After this, the program must store the string three times in another string, one after another one. Print the
result. For example: apple � appleappleapple
9. Write a program, which reads in a string. The string can have maximum 30 characters. After this, the program should remove any numbers from the beginning and from the end of the string.
Print the result. For example: 567apple345 � apple
10. Write a program, which reads in a string. The string can have maximum 70 characters. After this, the program should count how many times it happens, that a vowel is followed by another
vowel. Print the result. For example: aapplee � 2