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
What is a computer briage coures​
Stella [2.4K]

what's your choices for this question

4 0
3 years ago
Set of general format used to write program in any programming language?​
Pavlova-9 [17]
I think It might be Algorithms , algorithmic are a set of instructions that are used to solve a certain problem which of we create many programs…etc
4 0
3 years ago
Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the larges
denpristay [2]

Answer:

The code to this question can be defined as follows:

public double centeredAverage(ArrayList<Integer> nums) //defining a method centeredAverage that accepts an array nums

{

   if ((nums == null) || (nums.size() < 3))//define if block for check simple case value

   {

       return 0.0;//return float value

   }

   double sum = 0; //defining a double variable sum

   int smallest = nums.get(0);//defining integer variable and assign value

   int largest = nums.get(0);//defining integer variable and assign value

   for (int i = 0; i < nums.size(); i++) //defining for loop for stor ith value

   {

       int value = nums.get(i);//defining integer value variable to hold nums value

       sum = sum + value;//use sum variable for add value

       if (value < smallest)//defining if block to check value less then smallest

           smallest = value;//hold value in smallest variable  

       else if (value > largest)//defining else if block that checks value greater them largest value

           largest = value; //hold value in largest variable

   }

   sum = sum - largest - smallest;  // use sum to decrease the sum largest & smallest value

   return (sum / (nums.size() - 2)); //use return keyword for return average value

}

Explanation:

In the question, data is missing, that's why the full question is defined in the attached file please find it.

In the given code a method "centeredAverage" is used that accepts an array in its parameter and inside the method, if block is used that checks the cash value if it is true, it will return a float value.

In the next step, two integers and one double variable is defined, that use the conditional statement for check hold value in its variable and at the last use return keyword for return average value.

3 0
4 years ago
How do i use marketing in my everyday life
Alexxandr [17]
1. Subscribe to more emails
2. Look at billboards
3. Stop muting those pesky commercials
4. Listen to music
5. Step away from your work
8 0
3 years ago
In a 4-bit opcode.What is the maximum number of instructions allowed in your instrction set or your PROM?
lara31 [8.8K]

Answer:

(c) 16

Explanation:

An opcode is the short form for operation code which is also called instruction code. This code forms part of the instructions (instruction set) executed by the computer and it tells the computer the actual operation to be performed. The size of the opcode is the number of bits occupied by it. It is related to the instruction set size as follows;

2ˣ = I   ----------------(i)

Where;

x = opcode size or bit

I = maximum or total number of instructions allowed

From the question,

x = 4 bits.

Substitute this value into equation (i) as follows;

2⁴ = I

I = 16.

Therefore, the maximum number of instructions allowed in your instruction set or your PROM - Programmable read-only memory - is 16

7 0
3 years ago
Other questions:
  • Constructors ________. initialize instance variables when overloaded, can have identical argument lists when overloaded, are sel
    11·1 answer
  • Earthquakes happen in the Earth’s
    10·1 answer
  • A(n) _______ is text or a graphic you can click to jump to another file or to somewhere else in the same file. quizle
    12·1 answer
  • Write a Java program to accept an item's name and price from the user and output them to the console
    5·1 answer
  • A 10 Superscript negative 910−9​-F capacitor ​(11 nanofaradnanofarad​) is charged to 5050 V and then disconnected. One can model
    5·1 answer
  • A company decides to relocate its operations to another state in order to take advantage of some new business investment credits
    15·1 answer
  • What is the range for copper tape
    15·1 answer
  • I have no idea what I’m doing and this is due in 45 minutes
    7·1 answer
  • Difference between the four generations of computers in a tabular form​
    8·1 answer
  • Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. Fo
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!