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]
4 years ago
7

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

Computers and Technology
1 answer:
Dimas [21]4 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
Please help with this question​
babunello [35]

Answer:

whats the problem/question?

Explanation:

8 0
3 years ago
What are listed in the vertical columns across the top of the Event Editor?
jeka57 [31]

Answer:

a

Explanation:

7 0
4 years ago
Read 2 more answers
List three tacos there are several from the opening page of the help and support center.
s344n2d4d5 [400]
Mexican tacos sascSDV
8 0
4 years ago
What is the best free game designing program for windows
Nadusha1986 [10]
Python, Unity 3D, C++Notepad
8 0
3 years ago
When pasting a circle drawn by the presentation software drawing tool into a spreadsheet, that circle will go into the selected
puteri [66]

False.

When you copy an object/image or insert it manually into an Excel spreadsheet cell, what will happen is that the object will lie on a separate layer and it will float on the sheet independently from the cell. If you want it embedded inside the cell, you can either resize both the picture and adjust the cell or merge the cells.  


3 0
3 years ago
Read 2 more answers
Other questions:
  • Financial goals are helpful because they
    7·1 answer
  • How did mark watney survive the accident
    9·1 answer
  • The major types of wireless media are______________.
    6·1 answer
  • Why does dew form on grass overnight
    7·1 answer
  • In the ______ algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests till the
    11·1 answer
  • Yo, my Lenovo laptop keeps showing this screen but I can't sign in, can someone help me?
    5·2 answers
  • Explain the importance of system software in the computer​
    8·1 answer
  • F. Practical Questions
    7·1 answer
  • What kind of electronic communication might commonly be affected by citizen journalism?
    9·1 answer
  • I'll mark you the brainlest please help
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!