Sunday, 20 March 2016

C Program For Reverse a String Using Pointers

Problem:- Reverse a string using pointers c++ or C Program For Reverse A String Using Pointer or reverse a string using pointers c++ using while loop or c program to reverse a string using pointers with explanation or Reverse a string using pointers or Reverse a string using pointers in C or How to Reverse String using Pointer in C or C Program to Reverse String Without Using Library Function or String Reverse Using pointers or Reverse all words and string using pointer or c program to reverse a string using pointer and loop or Reverse the String Using FOR Loop and Pointers in C or Write a C program to reverse a string using pointers or C program to reverse a string using pointers.

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

Explanation:- Reverse a string using pointers is very likely as Stack program it also follow the same rule of Stack FILO (First In Last Out) in Reverse a string using pointers we are doing same when we are taking input from user at same time we are calculating the length of a String and with the help of length one by one we are transferring the character one by one from one string to another and until length is not become zero in while loop we put the same condition.

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

Extreme Recommended:- If this post is beneficial for you and you want Updates for New post then please 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, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.

HomeWork:- try to modify this program so the user can also take a space as an input. 

Solution:-

#include<stdio.h>
int main()
{
    char str[50];
    char revStr[50];

    char *strPtr = str;
    char *revPtr = revStr;

    int len = -1;

    printf("Enter The String Without Space:\n\n");
    scanf("%s",str);

    while(*strPtr)
  {
      strPtr++;
      len++;
    }

    while (len >= 0)
  {
      strPtr--;
      *revPtr = *strPtr;
      revPtr++;
      --len;
    }

    *revPtr='\0';
    printf("\n\nReverse String Is \n\n%s",revStr);
    return 0;
}

Output:-


C Program For Reverse a String Using Pointers

You May Also Like


1. C++ Program To Check Expression Parenthesis Is Valid Or Not Using If/Else Statements

2. C++Program To Check Age Between 40 To 60 Using If/Else Statements

3. C++ Program To Count Letters, Space, Digits, And Others Using If/Else Statements

4. C++Program To Check Date Validation (Valid Or Not) Using If/Else Statements

5. C++ Program To Print A Reverse Order Of Any Number Using Loop

6. C++ Program Print Truth Table Of XY+Z Using Loop

7. C++ Program Convert Decimal Number To Binary Number Using Loop




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

1 comment:

  1. This comment has been removed by the author.

    ReplyDelete