Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Q 18 Reverse character array
- public class Main
- {
- public static void main(String[] args) {
- Scanner sc= new Scanner(System.in);
- char[] arr ={'S','U','R','E','S','H'};
- int n = 6;
- for(int i=0 ; i<=n/2 ; i++){
- char c = arr[i];
- arr[i] = arr[n-i-1];
- arr[n-i-1] = c;
- }
- System.out.println("Reversed array is ");
- for(char c : arr){
- System.out.print(c);
- }
- }
- }
- /*
- Enter the number
- Reversed array is
- HSREUS
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement