C++ program to convert kth character to lowercase



Suppose we have a string S with N characters. S contains only three types of characters 'A', 'B' or 'C'. We also have another integer K. We have to print S after lowercasing the Kth character in it.

So, if the input is like K = 2; S = "AABACC", then the output will be "AaBACC"

Steps

To solve this, we will follow these steps −

S[K - 1] = S[K - 1] + 32 return S

Example

Let us see the following implementation to get better understanding −

#include <bits/stdc++.h> using namespace std; string solve(int K, string S){    S[K - 1] = S[K - 1] + 32;    return S; } int main(){    int K = 2;    string S = "AABACC";    cout << solve(K, S) << endl; }

Input

"AABACC"

Output

AaBACC
Updated on: 2022-03-03T07:15:49+05:30

217 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements