140. Program to reverse the content of a given string

 #include<stdio.h>

char ch[10],ele,temp=0,i,j,len;

void main()

{

    printf("Enter a string : ");

    scanf("%s",ch);

    ele=sizeof(ch)/sizeof(ch[0]);

    for(len=0;ch[len];len++);


    for(i=0,j=len-1;i<j;i++,j--)

    {

        ch[i]=ch[i]^ch[j];

        ch[j]=ch[i]^ch[j];

        ch[i]=ch[i]^ch[j];

    }

    printf("%s",ch);

}

Comments