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
What are some options available when using the Replace feature?
3241004551 [841]

Assuming that the user is talking about Microsoft Word, the options available when using the replace feature include replace, replace all, and find next. First, the Find what and Replace with boxes locates a word or phrase and replaces it with the new text. Selecting the replace option will update one instance while the replace all option will update all instances without stopping at each one. You can click on the Find Next several times until you come to the instance that you want to update.

8 0
3 years ago
Previous
spin [16.1K]

Answer:

A b output 0110111111001111

7 0
2 years ago
How do I make someone "Brainiest". <br> First person to reply will get "Brainiest"
xxTIMURxx [149]

Answer:

Usually when someone answers a question there would be an option to mark the brainliest. However, you only get one every like 24 hrs so if you already gave someone brainliest you can't give it to someone else for a while

Explanation:

6 0
2 years ago
Read 2 more answers
You should process the tokens by taking the first letter of every fifth word,starting with the first word in the file. Convert t
zhenek [66]

Answer:

See explaination

Explanation:

import java.io.File;

import java.io.IOException;

import java.util.Scanner;

import java.util.StringTokenizer;

public class SecretMessage {

public static void main(String[] args)throws IOException

{

File file = new File("secret.txt");

StringBuilder stringBuilder = new StringBuilder();

String str; char ch; int numberOfTokens = 1; // Changed the count to 1 as we already consider first workd as 1

if(file.exists())

{

Scanner inFile = new Scanner(file);

StringTokenizer line = new StringTokenizer(inFile.nextLine()); // Since the secret.txt file has only one line we dont need to loop through the file

ch = line.nextToken().toUpperCase().charAt(0); // Storing the first character of first word to string builder as mentioned in problem

stringBuilder = stringBuilder.append(ch);

while(line.hasMoreTokens()) { // Looping through each token of line read using Scanner.

str= line.nextToken();

numberOfTokens += 1; // Incrementing the numberOfTokens by one.

if(numberOfTokens == 5) { // Checking if it is the fifth word

ch = str.toUpperCase().charAt(0);

stringBuilder = stringBuilder.append(ch);

numberOfTokens =0;

}

}

System.out.println("----Secret Message----"+ stringBuilder);

}

}

}

5 0
3 years ago
Why is monitor called softcopy output device?​
Mademuasel [1]

Answer:

A display device is the most common form of output device it presents output visually on a computer screen.the output appears temporarily on the screen and can easily altered or erased,it is sometimes referred to as softcopy

7 0
2 years ago
Other questions:
  • ICT excel data homework
    10·1 answer
  • Which of the preventive strategies is described below: Violence often escalates. Behaviors like excessive complaing, hostility,
    10·1 answer
  • Pamela finds that she is constantly spelling the word “color” as “colour” when she is typing. Even though this is how the word i
    11·1 answer
  • A bank uses a computer program during the night to tell if the alarm should ring. Sensors in the bank set the following Boolean
    5·1 answer
  • Write c++ program bmi.cpp that asks the user bmi.cpp the weight (in kilograms) and height (in meters).
    12·1 answer
  • What is not true of credit scores?
    11·1 answer
  • What is thought to have caused the extinction of the dinosaurs?
    13·1 answer
  • Using hard disk to temporarily store data or instructions from ram is referred to as the
    12·1 answer
  • Define the terms network, LAN, WAN, and Internet.
    11·1 answer
  • Another word for asking a question of your data is to _____ it.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!