Question
print Characters in an odd position in the given word.
Enter a word
monkey
CHARACTERS IN Odd POSITION IN GIVEN WORD:
m n e
Share code with your friends
Share on whatsapp
Share on facebook
Share on twitter
Share on telegram
Code
import java.util.Scanner;
public class PrintOddPositionCharacters
{
public static void main(String[] args)
{
String wd="";
char ch=' ';
int i=0,len=0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a word");
wd = sc.next();
len=wd.length();
System.out.println("CHARACTERS IN Odd POSITION IN GIVEN WORD:");
for(i=0;i< len;i++)
{
ch=wd.charAt(i);
if((i+1)%2!=0)
{
System.out.print(ch+" ");
}
}
}
}
Coding Store
Sale
ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale