A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# program to reverse the words of a sentence
Q:

Write a C# program to reverse the words of a sentence

0

Write a C# program to reverse the words of a sentence

Sample Output:

Original String: Display the pattern like pyramid using the alphabet.  
                                                                       
Reverse String: alphabet. the using pyramid like pattern the Display

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;
public class Exercise28 {
 public static void Main() {
  string line = "Display the pattern like pyramid using the alphabet.";
  Console.WriteLine("\nOriginal String: " + line);
  string result = "";
  List < string > wordsList = new List < string > ();
  string[] words = line.Split(new [] {
   " "
  }, StringSplitOptions.None);
  for (int i = words.Length - 1; i >= 0; i--) {
   result += words[i] + " ";
  }
  wordsList.Add(result);
  foreach(String s in wordsList) {

   Console.WriteLine("\nReverse String: " + s);
  }
 }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now