Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a function that accepts a sentence as a parameter, and
returns the same with each of its words reversed. The
returned sentence should have 1 blank space between each
pair of words.
Demonstrate the usage of this function from a main program.
Example:
Parameter: “jack and jill went up a hill” Return Value:
“kcaj dna llij tnew pu a llih”

Answer Posted / vinay

public class Reversesentence {

public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("Enter the sentence");
String str=s.nextLine();

String[] str2=str.split(" ");
int l=str2.length;
for(int i=0;i<l;i++) {
StringBuffer sb=new StringBuffer(str2[i]);
StringBuffer revstr = sb.reverse();
System.out.print(" "+revstr);
}


}

}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why we use conio h in c?

1201


How to throw some light on the b tree?

1066


How can I rethow can I return a sequence of random numbers which dont repeat at all?

1180


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

1223


Can you define which header file to include at compile time?

1009


Difference between Function to pointer and pointer to function

1054


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

2122


What is the use of parallelize in spark?

1015


Does c have an equivalent to pascals with statement?

990


What is a static function in c?

1149


What is the heap in c?

1067


I have seen function declarations that look like this

1030


Explain about the functions strcat() and strcmp()?

1034


What is the purpose of clrscr () printf () and getch ()?

1060


Explain how do you search data in a data file using random access method?

1119