Ask user to enter his/her string and use stack structure to print out this after invert the string.
for example:
user string: computer
by using stack structure
print : retupmoc (inverted form of computer)
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sunny SharmaRank #223 · 11.1K reputationPosted Mar 20, 2014, 4:25 AM EDT
static void Main(string[] args)
{
var inStr = Console.ReadLine();
var chars = new Stack<char>();
if (string.IsNullOrEmpty(inStr.Trim()))
{
Console.WriteLine("No characters entered");
return;
}
foreach (var c in inStr)
{
chars.Push(c);
}
while(chars.Count>0)
{
Console.Write(chars.Pop());
}
}
You should rather Google it first... lol... Happy hours! Enjoy the code!!