1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kakasveta [241]
4 years ago
10

Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in

alphabetical order, and displays the sorted words separated by spaces. Write a Main() to test this funciton. The SortAndDisplayWords method will be tested with one, two, five, and ten words
Computers and Technology
1 answer:
sp2606 [1]4 years ago
3 0

Answer:

Following are the program in the C# Programming language.

//header

using System;

//define class

public class SortWords

{//define function

 public static void Display_Words(string[] word)

 {//set string type variable

   string a;

   //set the for loop for swapping the words

   for (int i = 0; i < word.Length; i++)

   {//set the for loop

     for (int j = 0; j < word.Length - 1; j++)

     {

   //set the if conditional statement for compare the string

       if (String.Compare(word[j], word[j + 1], StringComparison.Ordinal) > 0)

       {

       //perform swapping

         a = word[j];

         word[j] = word[j + 1];

         word[j + 1] = a;

       }

     }

   }

   //print message

   Console.WriteLine("Sorted Words: ");

   //set for loop to print the sorted list

   for (int i = 0; i < word.Length; i++)

   {//print space between the sorted characters

     Console.Write(word[i] + " ");

   }

 }

//define the main function

 public static void Main()

 {//print message

   Console.Write("Enter the number of words: ");

   //get input from the user

   int get_size = Convert.ToInt32(Console.ReadLine());

   //set string type array

   string[] word = new string[get_size];

   Console.WriteLine("Enter " + get_size + " words");

   //set for loop to get input in string type array

   for (int i = 0; i < get_size; i++)

   {

     word[i] = Console.ReadLine();

   }

   //call the function

   Display_Words(word);

 }

}

<u>Output</u>:

Enter the number of words: 5

Enter 5 words

h

e

l

l

o

Sorted Words:

e h l l o

Explanation:

Here, we define a class named "SortWords" and inside the class.

  • Define void type function "Display_words" and pass an string data type array argument "word".
  • Inside the function, we set two for loops to swapping the words and inside it we set the if conditional statement to compare the words then, perform swapping.
  • Set the for loop to print the sorted list

Finally, we define the main function in which we get inputs from the user, firstly we get the number of words then we get the words from the user. then call the function "Display_words".

You might be interested in
A lead views a specific page on your website, say, your case study page. You then send targeted follow-up content like one of yo
IRINA_888 [86]

Answer:

Behavioral Email                                

Explanation:

A behavioral email is an automated email which is sent to recipients on the basis of their behavior. These emails are sent after a user communicates with a business on social media, the company’s website, email, and other communication medium. Behavioral emails help to grow customer involvement and sales. Behavioral email can also be used as a marketing strategy, used by marketers to gather data about an email subscriber in order to send targeted content to that subscriber on the basis of his behavior or actions. When the marketer sends an email to the customer, it is appropriate for that customer, based on the data gathered and their current monitored behavior. Behavioral email helps to understand costumer needs. It helps to get an idea of a customers preferences by inspecting his behavior.

5 0
3 years ago
A user can set the security and privacy settings on what is displayed in the message bar from the ________ within the options me
djverab [1.8K]
Depends on the Operating System
6 0
3 years ago
Why would a brokered CD pay more than a regular CD?
Lana71 [14]

Brokered CDs may have higher or lower rates than those purchased directly from bans and credit unions. The general consensus here is that higher rates are usually available for direct purchases.

3 0
3 years ago
(viii) Word does not allow you to customize margins. <br>true/false:-​
Tatiana [17]
In Word, each page automatically has a one-inch margin. You can customize or choose predefined margin settings, set margins for facing pages, allow extra margin space to allow for document binding, and change how margins are measured.

I would say false
6 0
3 years ago
This allows you to access structure members.
MrMuchimi

Answer:

The correct option for the given question is option(B) i.e dot operator

Explanation:

Structure are collection of different datatypes member element .

Let us consider the example of structure

Struct test

{

int age ;

char name[45];

};

Here test is an "structure" which member is age of "integer" type and name of "String" type.if we have to access the member of structure,firstly we create structure variable name then after that we use dot operator which is also known as member access operator that access the members of structure.

struct test op;//  structure variable name

op.age=12; // access the member age

For example

Following is the code in c language :

#include <stdio.h> // header file

struct test // structure declaration

{

int age ;

char name[45];

};

int main() // main function

{

struct test op;//  structure variable name

op.age=12; // access the member age

printf("%d",op.age);

return 0;

}

Output:12

so correct answer is "dot operator"

3 0
3 years ago
Other questions:
  • What is the Documenter?
    10·1 answer
  • Respuestas de un examen parcial en introducción to computer
    12·1 answer
  • While performing disk and file maintenance on the company file server, you determine a user in the accounting department has bee
    13·2 answers
  • ________ consists of detailed, preprogrammed instructions that control and coordinate the computer hardware components in an inf
    11·1 answer
  • Suppose an initially empty stack S has performed a total of 15 push operations, 12 top operations, and 13 pop operations ( 3 of
    5·1 answer
  • Several programmers write individual code modules that are used for different processes in a vehicle. Individual tests have alre
    13·1 answer
  • 5. Developed by Paul Hawkins, it is a computer system
    14·1 answer
  • Which of the following You tubers uses the word "flip" as a curse word
    8·2 answers
  • What are some recent inventions that have improved the quality of your life?
    10·1 answer
  • During an IFR flight in IMC, you enter a holding pattern (at a fix that is not the same as the approach fix) with an EFC time of
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!