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
nikklg [1K]
3 years ago
9

g given the signature of a function void ascendingwords(char sentence[], int size), where sentence is an array of characters(i.e

. a null terminated string) and size is the amount of memory allocated for the buffer sentence. Complete the function to print the words in the sentence in an ascending order. the user needs to provide the input. for example if the sentence is Programming is Fun. then the function should print the output Fun is Programming
Computers and Technology
1 answer:
BlackZzzverrR [31]3 years ago
6 0

Answer:

// This program is written in C++ programming language

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

// Function starts here

string ascendingwords(string sentence)

{

// Calculate length of input text

int len = sentence.length() - 1;

// Create a begin and end variable

int begin, end = len + 1;

// Declare and initialize an output string

string output = "";

// Perform iteration while there's still some text in the input string

while(len >= 0)

{

if(sentence[len] == ' ')

{

begin = len + 1;

while(begin != end)

output += sentence[start++];

output += ' ';

end = len;

}

len--;

}

begin = 0;

while(begin != end)

output += sentence[begin++];

return output;

}

// Main method starts here

int main()

{

// Declare string

string sentence;

// Prompt user for input

cout<<"Enter a string: ";

cin>>sentence;

cout <<ascendingwords(sentence);

return 0;

}

You might be interested in
Which term describes the distance from one point on a wave to the same point on the next wave?
Sliva [168]
<span>Wavelength

</span>the wavelength<span> is the </span>spatial period<span> of a periodic wave—the distance over which the wave's shape repeats.</span><span> It is thus the </span>inverse<span> of the </span>spatial frequency<span>. Wavelength is usually determined by considering the distance between consecutive corresponding points of the same </span>phase<span>, such as crests, troughs, or </span>zero crossings<span> and is a characteristic of both traveling waves and </span>standing waves<span>, as well as other spatial wave patterns.</span>
7 0
3 years ago
Read 2 more answers
Write a function decimalToBinaryRecursive that converts a decimal value to binary using recursion. This function takes a single
Delicious77 [7]

Answer:

Check the explanation

Explanation:

#include <iostream>

#include <string>

using namespace std;

string decimalToBinaryRecursive(int n) {

   if(n == 0) {

       return "0";

   } else if(n == 1) {

       return "1";

   } else {

       int d = n % 2;

       string s;

       if (d == 0) {

           s = "0";

       } else {

           s = "1";

       }

       return decimalToBinaryRecursive(n/2) + s;

   }

}

int main() {

   cout << decimalToBinaryRecursive(0) << endl;

   cout << decimalToBinaryRecursive(1) << endl;

   cout << decimalToBinaryRecursive(8) << endl;

   return 0;

}

See the output image below

5 0
3 years ago
Write a program that creates an integer array with 40 elements in it. Use a for loop to assign values to each element of the arr
iogann1982 [59]

Answer:

public class Main

{

public static void main(String[] args) {

 int[] numbers = new int[40];

 for (int i=0; i<40; i++){

     numbers[i] = i * 3;

 }

 for (int i=0; i<40; i++){

     System.out.println(numbers[i]);

 }

}

}

Explanation:

*The code is in Java.

Initialize an integer array with size 40

Create a for loop that iterates 40 times. Inside the loop, set the number at index i as i*3

i = 0, numbers[0] = 0 * 3 = 0

i = 1, numbers[1] = 1 * 3 = 3

i = 2, numbers[2] = 2 * 3 = 6

.

.

i = 39, numbers[39] = 39 * 3 = 117

Create another for loop that iterates 40 times and prints the values in the numbers array

8 0
3 years ago
Why does dew form on grass overnight
12345 [234]
Dew forms on grass when the cold air form the night blends with the hot air from the morning therefore creating dew on grass
8 0
3 years ago
What are the steps to creating a blank database? Use the drop-down menus to complete them.
Alenkasestr [34]

Answer:

What are the steps to creating a blank database? Use the drop-down menus to complete them.

click the file tab, and click new

Under the available Templates category, click Blank Database.

Specify a name and location for the database.

Click create.

Explanation:

Just did it on Edge :)

5 0
3 years ago
Other questions:
  • What is microsoft excel
    12·1 answer
  • Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of integer
    14·2 answers
  • Which of the following is the correct ordering of operating systems, oldest to newest?
    5·2 answers
  • What will be displayed if the following Java code segment is run? System.out.println("one "); System.out.print("two "); System.o
    12·1 answer
  • If you misspell a word in your Java program it may be true that I. the program will not compile II. the program may compile, but
    6·1 answer
  • The East Coast sales division of a company generates 62 percent of total sales. Based on that percentage, write a Python program
    7·1 answer
  • What is a complier in computers
    9·2 answers
  • How is the architecture converted into software code? Elaborate the steps its passes through with help of examples / Diagram.
    15·1 answer
  • What is Utility Software ? Name any two utility programs. <br>​
    15·2 answers
  • One of 34 possible _________________ can be assigned to each axis of classification in the seven-character code.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!