Saturday, May 22, 2010

Visual C#...I'm trying to create a program on C# that asks you to enter 5 words(one at time) and print out in

reverse order like this: Please enter 1st word:


dust


etc. until it goes - sentence is: another one bites the dust.


I've done it but the sentence comes up with no spaces?


string wordone ;


string wordtwo ;


string wordthree ;


string wordfour ;


string wordfive ;


Console.WriteLine("Please enter your 1st word: ");


wordone = Console.ReadLine();


Console.WriteLine("Please enter your 2nd word: ");


wordtwo = Console.ReadLine();


Console.WriteLine("Please enter your 3rd word: ");


wordthree = Console.ReadLine();


Console.WriteLine("Please enter your 4th word: ");


and so on and then last bit is:


Console.WriteLine( wordfive + wordfour + wordthree + wordtwo + wordone );


Console.ReadLine();

Visual C#...I'm trying to create a program on C# that asks you to enter 5 words(one at time) and print out in
replace each + with + " " +
Reply:I'd probably not write the program the way you did, but otherwise just change your last line:





Console.WriteLine(wordfive + " " + wordfour + " " ...etc.





or use





concat(wordfive, " ", wordfour, " " .... etc)


No comments:

Post a Comment