C++ Program To Reverse String Without Using String Functions














































C++ Program To Reverse String Without Using String Functions



Description:
Given a string, this program helps to reverse it.
First length of the string is calculated using eol.
Then the first character is swapped with last and second with second last and so on.
After the loop is finished we get the required string.

Program Code: 
#include <iostream> using namespace std; void RevString (char S[]) { int i; int l=0; for ( i=0;S[i]!='\0';i++) { l++; } cout<<"\nLength:"<<l; for (i=0;i<l/2;i++) { char t=S[i]; S[i]=S[l-i-1]; S[l-i-1]=t; } cout<<"\nReversed String:"; for ( i=0;S[i]!='\0';i++) { cout<<S[i]; } } int main() { char S[25]={"CppSecrets"}; cout<<S; RevString(S);
return 0;
}
Output:



More Articles of Avikrit Kohli:

Name Views Likes
C++ Program To Insert At Bottom Of Stack Using Recursion 1363 1
Python Program To Extract Data From Excel 699 1
C++ Program To Reverse Line In Text File 4379 1
C++ Program To Implement Simpsons 3/8th rule 1172 2
C++ Program To Read Text File Word By Word 4331 1
Program To Display Level Order Transversal Using Queue 572 1
C++ Program To Find Length Of Linked List 2643 1
C++ Program To Search An Element Recursively In Linked List 1172 1
C++ Program To Delete Element In Array At Particular Position 1504 1
C++ Program To Find The Minimum In Subarray Of Size k Using Deque 656 2
To Find Negation of Number Using Operator Overloading 925 1
C++ Program To Reverse Linked List Recursively 3003 1
C++ Program To Sort Two Arrays And Inserting Result In Third array 1250 1
To Sort Array Of Integers Using Bubble,Insertion And Selection Sort 1560 1
C++ Program To Implement Stack Using Arrays 2801 1
C++ Program To Balance Parenthesis Using Stack 2127 1
Python Program To Add Source Code of A Webpage 661 1
C++ Program To Insert Element In Array At Given Position 2164 1
C++ Program To Reverse Each Word In Text File 1156 1
C++ Program to Swap two numbers without using third variable 681 2
C++ Program To Reverse String Without Using String Functions 1304 20
C++ Program To Reverse Stack Recursively 1527 1
C++ Program To Find Sum Of Fibonacci Series Using Recursion 3645 1
C++ Program To Create And Display Text File 968 1
C++ Program To Find Root Using Bisection Method 5631 1
C++ Program To Implement Queue Using Array 4813 2
C++ Program To Sort Stack Recursively 1973 1
C++ Program To Create Tower Of Hanoi 6897 1

Comments