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

String Manipulation and Sorting Tasks

Uploaded by

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

String Manipulation and Sorting Tasks

Uploaded by

sabarin2026
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1)print the letters only in a string

Eg 1: Input: sabari10
output:sabari

2)count the character occurance in string

input
sab
output
s-1
a-1
b-1
3)

Input: arr1[] = { 1, 3, 4, 5}, arr2[] = {2, 4, 6, 8}


Output: arr3[] = {1, 2, 3, 4, 4, 5, 6, 8}

Input: arr1[] = { 5, 8, 9}, arr2[] = {4, 7, 8}


Output: arr3[] = {4, 5, 7, 8, 8, 9}

4)

Oddly Even Problem Statement


Given a maximum of 100 digit numbers as input, find the difference between the sum
of odd and even position digits
Test Cases
Case 1
• Input: 4567
• Expected Output: 2
Explanation : Odd positions are 4 and 6 as they are pos: 1 and pos: 3, both have
sum 10. Similarly, 5 and 7 are at even positions pos: 2 and pos: 4 with sum 12.
Thus, difference is 12 – 10 = 2
Case 2
• Input: 5476
• Expected Output: 2
Case 3
• Input: 9834698765123
• Expected Output: 1

5)

A doctor has a clinic where he serves his patients. The doctor’s consultation fees
are different for different groups of patients depending on their age. If the
patient’s age is below 17, fees is 200 INR. If the patient’s age is between 17 and
40, fees is 400 INR. If patient’s age is above 40, fees is 300 INR. Write a code to
calculate earnings in a day for which one array/List of values representing age of
patients visited on that day is passed as input.
Note:

Age should not be zero or less than zero or above 120


Doctor consults a maximum of 20 patients a day
Enter age value (press Enter without a value to stop):
Example 1:
Input
20
30
40
50
2
3
14
Output
Total Income 2000 INR
Note: Input and Output Format should be same as given in the above example.
For any wrong input display INVALID INPUT
Output Format
Total Income 2100 INR

6)
Given a sentence with numbers representing a word’s location in the sentence,
embedded within each word, and return the sorted sentence.

Note: We are using a maximum of 0-9 numbers only for 1 sentence

Example 1

Input: is1 Thi0s T3est 2a


Output: This is a Test
Example 2

Input: t2o j3oin 4WonderBiz I0 Technolog5ies wan1t


Output: I want to join WonderBiz Technologies

7)write a program example for bubble sort

You might also like