Array-promo

Question

program to print reverse of  word

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

				
					
import java.util.Scanner;
public class reverseOfWord 
{  
    public static void main(String[] args)
    {  
        String wd="",wd1="";
        char ch=' ';
        int i=0,len=0;
        Scanner sc = new Scanner(System.in);    
        
        System.out.println("Enter a word");   
        wd = sc.next(); 
        
        System.out.println("given word:"+wd);
        len=wd.length();
        for(i=0;i< len;i++)
        {
            ch=wd.charAt(i);
            
            wd1=ch+wd1;
                
            
        }
        System.out.println("Reverse of word:"+wd1);
    }  
}    

				
			

Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *