top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Write a program which accepts 2 strings from the user and performs the following operation on it?

+1 vote
811 views

Write a program which accepts 2 strings from the user and performs the following operation on it.
Example –
string1 = “Hello”
string2 = “World”
string3 must be “HellodlroW”

Both strings must be concatenated but after reversing the second string (as shown in string3 above).

posted May 14, 2017 by Azhar Keer

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

public class StringConcatTest {

/**
 * @param args
 */
public static void main(String[] args) {

    Scanner sc=new Scanner(System.in);
    System.out.println("Enter two Strings");
    String s1=sc.nextLine();
    String s2=sc.nextLine();

    String s3=new StringBuilder(s1).append(new StringBuilder(s2).reverse()).toString();
    System.out.println(s3);

}

}

answer May 25, 2017 by S Santhosh
i need c code for this program
Similar Questions
+2 votes

Input:
arr = {'a', 'b'}, length = 3

Output:
aaa
aab
aba
abb
baa
bab
bba
bbb

+2 votes

Given 2 strings, a and b, return a string of the form shorterString+longerString+shorterString, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0). If input is "hi" and "hello", then output will be "hihellohi".

...