Sunday, 22 October 2017

Reverse

#include<stdio.h>
int main()
{
    char a[50];
    int l,i=0,j,temp;
    printf("Enter a String/Number: ");
    gets(a);
    for(l=0;a[l]!='\0';l++); 
     //to determine length of String
    j=l-1;   // l is the length of String
    for(i=0;i<l/2;i++)
    {
        temp=a[i];
        a[i]=a[j];
        a[j]=temp;
        j--;
    }
    puts(a);
    return 0;


}

Output Enter a String/Number: 12345
                        54321

1 comment:

  1. plz provide the code using command line argument

    ReplyDelete

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...