[go: up one dir, main page]

0% found this document useful (0 votes)
34 views2 pages

String and Array Programming Tasks

This document contains instructions for practical 5 of the CEC 101: Computer Programming course. It includes 8 questions related to strings and arrays - finding a number in a number spiral, modifying an array to be increasing, checking if a word is a palindrome, counting words in a sentence, reversing an array without a new array, separating vowels and consonants in a string, checking if a matrix is symmetric, and calculating mean height and weight from student data. Students are asked to write programs to solve each of these string and array problems.

Uploaded by

DHRUV SONI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

String and Array Programming Tasks

This document contains instructions for practical 5 of the CEC 101: Computer Programming course. It includes 8 questions related to strings and arrays - finding a number in a number spiral, modifying an array to be increasing, checking if a word is a palindrome, counting words in a sentence, reversing an array without a new array, separating vowels and consonants in a string, checking if a matrix is symmetric, and calculating mean height and weight from student data. Students are asked to write programs to solve each of these string and array problems.

Uploaded by

DHRUV SONI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like