CEC 101: Computer Programming
Civil Engineering Autumn 2023-24
Practical 5: String and Array
Q.1. A number spiral is an infinite grid whose upper-left square has the
number 1. Here are the first five layers of the spiral: -
Your task is to find out the number in row y and column x.
Q.2. You are given an array of n integers. You want to modify the array so
that it is increasing, i.e., every element is at least as large as the previous
element.
On each move, you may increase the value of any element by one. What
is the minimum number of moves required?
Q.3. A palindrome word is a word that reads the same backwards as
forwards like madam, racecar, etc. Write a program to input a word from
the user and check if it is a palindrome word or not.
Q.4. Write a program to take a sentence separated by spaces as input
from the user and count the number of words in that sentence.
Q.5. Write a program to reverse an array of size n without creating
another array.
Q.6. Given a string s, separate the vowels and consonants into two
strings v and c, preserving their relative order.
Q.7. Write a program to input a 3x3 matrix and print whether it is a
symmetric matrix or not. A symmetric matrix is a matrix that is equal to
its transpose.
Q.8. Write a program to input the height and weights of all the students
of a class and find the mean height and weight.