- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements