camel case notation


CamelCase notation is a common name for the practice of writing compound words or phrases where the words are. joined without spaces, and each word is capitalized within the compound. This practice is known by a large variety. of names, including BiCapitalization, InterCaps, MixedCase, etc.

example:

input:

// CPP program to convert given sentence 
/// to camel case.
#include <bits/stdc++.h>
using namespace std;
 
// Function to remove spaces and convert
// into camel case
string convert(string s)
{
    int n = s.length();
 
    int res_ind = 0;
 
    for (int i = 0; i < n; i++) {
 
        // check for spaces in the sentence
        if (s[i] == ' ') {
 
            // conversion into upper case
            s[i + 1] = toupper(s[i + 1]);
            continue;
        }
 
        // If not space, copy character
        else
            s[res_ind++] = s[i];        
    }
 
    // return string to main
    return s.substr(0, res_ind);
}
 
// Driver program
int main()
{
    string str = "this is an codeareana blog";
    cout << convert(str);
    return 0;
}



output:

ThisIsAnCodearenaBlog







Comments

Popular posts from this blog

variable scope in c++

c++ programing language