My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to reverse a string without using inbuilt function

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
void main()
{  clrscr();
   char s[50];
   cout<<"enter the string:"<<endl;
   cin>>s;
   int i,m;
   i=0;
   while(s[i]!='\0')
   { i++;}
   for(int j=0;j<(i-1)/2;j++)
   {  m=s[j];
     s[j]=s[i-j-1];
     s[i-j-1]=m;        }

   cout<<"reverse string is:"<<endl;
   cout<<s;
   getch();
   }

0 comments: