Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions C++/Program11/Program11.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//Camel case the input stirng

#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

void main() {

string str;
char cstr[100];
cin.getline(cstr, 100);
str = cstr;
for (int i = 0; i < str.length(); i++) {
if (i == 0)
str[i] = toupper(str[i]);
else if (str[i - 1] == ' ')
str[i] = toupper(str[i]);
}
cout << "\n" << str;
}
5 changes: 5 additions & 0 deletions C++/Program11/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
this program Camel cases an input sentence

Example:
input: Camel case this sentence
output: Camel ase This Sentence
48 changes: 48 additions & 0 deletions C++/program-10/Program10.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Program 10.cpp
// Reverse words in a given string

#include <iostream>
#include<string>

using namespace std;

string reverse_string(string str) {
string temp_str = str;
int index_pos = 0;

for (int x = temp_str.length() - 1; x >= 0; x--)
{

str[index_pos] = temp_str[x];
//cout << str[index_pos];
index_pos++;
}
return str;
}

int main()
{
//taking string input
string str;
char str1[100];
cout << "String: ";
cin.getline(str1, 25);

int j = 0, begin, end, temp;

//reverse whole string
str = reverse_string(str1);
//reverse each word seperately
for (int i = 0; i < str.length(); i++) {
if (str[i] == ' ' || str[i] == '\0') {
for (begin = j, end = i - 1; begin < (i + j) / 2; begin++, end--) {
temp = str[begin];
str[begin] = str[end];
str[end] = temp;
}
j = i + 1;
}
}
//printing the words
cout << str;
}
8 changes: 8 additions & 0 deletions C++/program-10/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Program to Reverse the words in the string:
Example:
input
String: I love hactoberfest

Output
hactoberfest love I