Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 08-08-2009
Member
 
Join Date: Aug 2009
Posts: 12
How to use a loop function to reverse a counter string?

Hi,

How to use a loop function to reverse a counter string?

Thanks,
Reply With Quote
  #2  
Old 08-08-2009
Member
 
Join Date: Apr 2008
Posts: 22
Re: How to use a loop function to reverse a counter string?

Using a for Loop to Reverse a String

Try this example:

Code:
<HTML>
<BODY>
<H1>
<SCRIPT> 
      var newString = ""; 
      var theString = "This is a test"; 
      var counter = theString.length; 

      for (counter  ;counter > 0 ;counter -- ) { 
         newString += theString.substring(counter-1, counter); 
      } 
      document.write(theString + " reversed is " + newString + "!"); 
   </SCRIPT>
</H1>
</BODY>
</HTML>
Reply With Quote
  #3  
Old 08-08-2009
Member
 
Join Date: May 2008
Posts: 29
Re: How to use a loop function to reverse a counter string?

Using a Do/While Loop to Reverse a Text String

Try this example

Code:
<HTML>
<BODY>
<H1>
<SCRIPT> 
      var newString = ""; 
      var theString = "string"; 
      var counter = theString.length; 
      do 
      { 
        newString += theString.substring(counter-1, counter); 
        counter--; 
      } 
      while (counter > 0 ); 
      document.write(theString + " reversed is " + newString + "!"); 
   </SCRIPT>
</H1>
</BODY>
</HTML>
Reply With Quote
  #4  
Old 08-08-2009
Member
 
Join Date: Aug 2009
Posts: 10
Re: How to use a loop function to reverse a counter string?

Try this:

Code:
#include
#include
#include

void main()
{
char str[10],temp;
int i,len;
printf("Enter String : ");
scanf("%s",str);
len=strlen(str)-1;
for(i=0;i
{
temp=str[i];
str[i]=str[len];
str[len--]=temp;
}
printf("%s",str);
getch();
I hope this helps you.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to use a loop function to reverse a counter string?"
Thread Thread Starter Forum Replies Last Post
How to fix reverse arrow key function on Mac Office 2011 BonnieT Windows Software 16 26-11-2011 02:42 PM
Reverse Port Forwarding Wizard cannot function in Windows 7 Appaji Operating Systems 4 18-04-2010 05:15 AM
How the reverse() function can be used in C++ BossBattle Software Development 5 20-02-2010 04:55 PM
program to reverse a string in java. Deepest BLUE Software Development 3 26-11-2009 11:03 PM


All times are GMT +5.5. The time now is 05:36 AM.