-->

program to reverse a string using pointer

using codeblocks
--------------------------------------------------------------------------------------------
//program to reverse a string using pointer//comment of program
#include <stdio.h>                         //header file
#include<string.h>
int main()                              //main function
{
    char name[40];                     //character declaration
    char *p;                          //pointer declaration.
    int length;
    puts("enter string\n");           //display of message
    gets(name);                      // gets data/string
    length=strlen(name);             //stores length os string
    p=name+length;     
 // assigning total address as in given string; it becomes total taken from variable length starting from //0.
    //p=name takes address location 0 to pointer.
    while(p>=name)                 //the value of 'p' decreases from total location  until it reaches 0.
    {
        putchar(*p);                 //prints the value stored in particular location
        p--;                             //decreases the value
    }
    return 0;
}
----------------------------------------------------------------------------------------------
using turbo c++
----------------------------------------------------------------------------------------------
//program to reverse a string using pointer//comment of program
#include <stdio.h>                         //header file
#include<string.h>
#include<conio.h>
int main()                              //main function
{
    char name[40];                     //character declaration
    char *p;                          //pointer declaration.
    int length;
    puts("enter string\n");           //display of message
    gets(name);                      // gets data/string
    length=strlen(name);             //stores length os string
    p=name+length;     
 // assigning total address as in given string; it becomes total taken from variable length starting from //0.
    //p=name takes address location 0 to pointer.
    while(p>=name)                 //the value of 'p' decreases from total location  until it reaches 0.
    {
        putchar(*p);                 //prints the value stored in particular location
        p--;                             //decreases the value
    }
getch();
    return 0;
}

program to reverse a string using pointer.

using codeblocks
------------------------------------------------------------------------------------------
//program to reverse a string using pointer//comment of program
#include <stdio.h>                         //header file

int main()                              //main function
{
    char name[40]="ramesh Shrestha";  //assignment of string
    char *p;                          //pointer declaration
    p=name+15;  //p=name takes address location 0 to pointer.

  // assigning total address as in given string; it becomes 15 starting from 0
    while(--p>=name)                 //the value of 'p' decreases from location 15 until it reaches 0.
    {
        putchar(*p);                 //prints the value stored in particular location
    }
    return 0;
}
 ----------------------------------------------------------------------------------------------------

using turboc++
--------------------------------------------------------------------------------------------

//program to reverse a string using pointer//comment of program
#include <stdio.h>                         //header file
#include<conio.h>

int main()                              //main function
{
    char name[40]="ramesh Shrestha";  //assignment of string
    char *p;                          //pointer declaration
    p=name+15;       //p=name takes address location 0 to pointer.
                
// assigning total address as in given string; it becomes 15 starting from 0
    while(--p>=name)                 //the value of 'p' decreases from location 15 until it reaches 0.
    {
        putchar(*p);                 //prints the value stored in particular location
    }
getch();
    return 0;
}