Thursday, November 22, 2012

C PROGRAM FOR REVERSING THE STRING


/*  C PROGRAM FOR REVERSING THE STRING */
#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
       int n,i;
      char a[20];
      clrscr();
      printf("\n\t\tREVERSING THE STRING");
      printf("\n\t\t--------------------");
      printf("\n\t\tINPUT");
      printf("\n\t\t-----");
      printf("\nEnter the string:");
      scanf("%s",a);
      n=strlen(a);
      printf("\n\t\tOUTPUT");
      printf("\nThe result is:");

    for(i=n;i>=0;i--)
    {
       printf("%c",a[i]);
     }
 getch();
}


           

















OUTPUT:


     REVERSING THE STRING
                --------------------
                INPUT
                     Enter the string:RAJKUMAR
               OUTPUT
                   The result is: RAMUKJAR

0 comments:

Post a Comment