forked from ravya1108/hactoberfest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create reverse_string_dhanashrisonawane28.cpp
Reverse String Program ravya1108#94
- Loading branch information
1 parent
1c13757
commit 8e0e606
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
#include <string> | ||
|
||
int main() { | ||
std::string input; | ||
std::cout << "Enter a string: "; | ||
std::cin >> input; | ||
|
||
std::string reversed = ""; | ||
int length = input.length(); | ||
|
||
// Reverse the string | ||
for (int i = length - 1; i >= 0; i--) { | ||
reversed += input[i]; | ||
} | ||
|
||
std::cout << "Reversed string: " << reversed << std::endl; | ||
|
||
return 0; | ||
} |