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
Naddika [18.5K]
3 years ago
7

Write a function that will alphabetize a string WITHOUT using the sort function :

Computers and Technology
1 answer:
Dimas [21]3 years ago
7 0

Answer:

here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to alphabetize the input string

void alphabetize(string &str)

{

// find the length of string

 int n=str.size();

 

  for(int x=0;x<n;x++){

      for(int y=x+1;y<n;y++)

      {  

          //swap the character

          if(str[x]>str[y]){

              char ch=str[x];

              str[x]=str[y];

              str[y]=ch;

          }

      }

  }

 

  cout<<"alphabetize string is: "<<str<<endl;;

 

}

int main()

{// string variable to read input

  string inp;

 

  cout<<"Please Enter a String in lowercase :";

  //reading the input

  cin>>inp;

  // call function with inp argument

  alphabetize(inp);

  return 0;

  }

Explanation:

Declare a variable "inp" of string type and assign the input string to it. call the alphabetize() function with argument "inp".In the alphabetize(),find the length  of input string.Then travers the string and if a character is greater than any  next character in the string then swap it, so that all the character are sorted.

Output:

Please Enter a String in lowercase :helloworld                                                                                                                

alphabetize string is: dehllloorw

You might be interested in
Why would a network administrator want to filter certain ports when capturing data such as FTP traffic
hjlf

Answer:

To avoid receiving malware-infected files like spam.

Explanation:

Hackers use malware to gain unauthorized access to company files and information for personal gain. Files infected by the malware can infect other systems or files. There are various types of malware namely; virus, trojan horse, worm, spyware, ransomware, adware etc.

5 0
2 years ago
The tcp/ip ____ layer commonly uses the transmission control protocol (tcp) to maintain an error-free end-to-end connection.
aleksklad [387]
The answer would be the TCP/IP Application Layer.
6 0
3 years ago
Can I get money for the cars which I sell in my showroom mod in gta v(5)
nikitadnepr [17]

Answer:

Yes you can

Explanation:

5 0
3 years ago
________ is used to undo unwanted database changes.
riadik2000 [5.3K]
Backward Recovery would be the answer.

(:
5 0
3 years ago
Read 2 more answers
Would you expect all the devices listed in bios setup to also be listed in device manager? would you expect all devices listed i
katen-ka-za [31]
<span>Would you expect all the devices listed in bios setup to also be listed in device manager? = Yes
Would you expect all devices listed in device manager to also be listed in bios setup? = No, the BIOS doesn't know anything about your peripherals etc. that is all managed by the OS.</span>
6 0
2 years ago
Other questions:
  • If you want to copy text formatting from one area of your document to another area, _____.
    5·2 answers
  • Recall that through either photographic or computer technology, researchers can make a composite (or "averaged") face out of any
    11·1 answer
  • Which of the following about if statement is true? A. The condition is a Boolean expression B. A Boolean expression is something
    15·1 answer
  • Rob Janoff believes that technology should not be used too
    11·1 answer
  • Given the following function definition
    13·1 answer
  • your computer running Windows 10 is doing some very strange things with operating system you are fairly certain it is not a hard
    13·2 answers
  • In general, smartphones do NOT hold as much personal information as tablets.
    11·1 answer
  • The term generally used to describe storage systems that function at high speeds is:
    12·1 answer
  • private members of a class are accessible only from _____________ of the same class or from their friends
    12·1 answer
  • ...................is a high level, structured , open source programming language​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!