Menu
Question Index
...

Given the input word as a character array, then write a program to prefix every character in the input word.

Input (char[], char) Output (char[])
{'B', 'o', 'o', 'k'}, 'T' {'T', 'B', 'T', 'o', 'T', 'o', 'T', 'k'}
{'D', 'h', 'o', 'n', 'i'}, 'E' {'E', 'D', 'E', 'h', 'E', 'o', 'E', 'n', 'E', 'i'}
{'M', 'o', 't', 'h', 'e', 'r'}, 'O' {'O', 'M', 'O', 'o', 'O', 't', 'O', 'h', 'O', 'e', 'O', 'r'}
{'W', 'e', 'l', 'c', 'o', 'm', 'e'}, 'R' {'R', 'W', 'R', 'e', 'R', 'l', 'R', 'c', 'R', 'o', 'R', 'm', 'R', 'e'}
{'T', 'a', 'b', 'l', 'e'}, 'P' {'P', 'T', 'P', 'a', 'P', 'b', 'P', 'l', 'P', 'e'}



class PrefixEveryCharacterInArray
{
    public static void main(String s[])
    {
        char input[] = {'B', 'o', 'o', 'k'};
        char result[] = prefixEveryCharacter(input, 'T');
        System.out.print("After prefixing every character in the input word : ");
        for (char ch : result)
        System.out.print(ch + " ");

    }


    public static char[] prefixEveryCharacter(char[] input, char prefix) {
    }

}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App