Sunday, 20 March 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


Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment