3/20/2016

C Program to Reverse String Without Using Library Function

Problem:- C Program to Reverse String Without Using Function or C Program to Reverse String Without Using Library Function or Write a C program to reverse the string without using strrev()? or Reverse string or C program to reverse a string without using library function or Reversing a String Program or Reverse string c code without using string function or C program to find reverse of a string or C Program For Reverse A String Using Library Function or Different methods to reverse a string in C/C++ or  Reverse String Without Using Library Function [ Strrev ] or c program to reverse a string without using string functions.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Explanation:- We can reverse the string without using the library function and strrev(). In this program, I am reverse the string without using strrev(), or reverse the string we have to find the length of the string. After finding the length of the string run a Loop from the last index to string the first index, and in each iteration decrease the last index by 1 so we can reverse the full string, this is similar problem to reverse the sentence, or we can solve this problem by using a strrev() library function. instead, for using library function always solve the problem with own logic, in this way your logic building and implementing the existing problem will benefit to you.


Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.


Solution:-

#include<stdio.h>
#include<string.h>

void main()
{
/*Visit - www.programmingwithbasics.com*/
   
    printf("=====================================");
    printf("\nVisit - www.programmingwithbasics.com");
    printf("\n=====================================");

   char str[100], temp;
   int i, j = 0;

   printf("\n\nEnter The String: ");
   gets(str);

   i = 0;
   j = strlen(str) - 1;

   while (i < j) 
   {
      temp = str[i];
      str[i] = str[j];
      str[j] = temp;
      i++;
      j--;
   }

   printf("\n\nReverse String Is: %s\n\n", str);
   
   return (0);
}

Output:-

C Program to Reverse String Without Using Library Function

You May Also See


1. C++ Program To Check Number Is Armstrong Or Not Using If/Else Statements

2. C++ Program To Find Character Is Vowel Or Not Using If/Else Statements

3. C++ Program To Check Number Is Even Or Odd Using If/Else Statements

4. C++ Program To Check Number Is Prime Or Not Using If/Else Statements

5. C++ Program To Check Character Is Uppercase, Lowercase Alphabet Or A Digit Or A Special Symbol Using If/Else Statements


No comments:

Post a Comment