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
Airida [17]
3 years ago
6

Write a program that removes all spaces from the given input.

Computers and Technology
1 answer:
sasho [114]3 years ago
5 0

Explanation:

#include<iostream>

#include<string.h>

using namespace std;

char *removestring(char str[80])

{

   int i,j,len;

   len = strlen(str);

   for( i = 0; i < len; i++)

   {

       if (str[i] == ' ')

       {

           for (j = i; j < len; j++)

               str[j] = str[j+1];

           len--;

       }

   }

   return str;

}

int main ()

{  

char  str[80];

   cout << "Enter a string : ";

   cin.getline(str, 80);

   strcpy(removestring(str), str);

   cout << "Resultant string : " << str;

   return 0;

}

In this program the input is obtained as an character array using getline(). Then it is passed to the user-defined function, then each character is analyzed and if space is found, then it is not copied.

C++ does not allow to return character array. So Character pointer is returned and the content is copied to the character array using "strcpy()". This is a built in function to copy pointer to array.

You might be interested in
Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia"). Assume also that stdin is a v
zaharov [31]

Answer:

// program in java.

import java.util.*;

// class definition

class Main

{// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // object to read input

Scanner scr=new Scanner(System.in);

 // ask to enter name

System.out.print("Enter Your name: ");

 // read name from user

String NAME=scr.nextLine();

// print message

System.out.println("Greetings,"+NAME);

     

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read name from user with the help of scanner object and assign it to variable "NAME".Then print a Greetings message as "Greetings,NAME" where NAME will be  replaced with user's input name.

Output:

Enter Your name: Rachel                                                                                                    

Greetings,Rachel

5 0
2 years ago
Letm1, m2,···mnbe distinct numbers on the number line, in the increasing order. Your goalis to color all of them blue. You have
siniylev [52]

Answer:

Following are the algorithm to this question:

y = 0 //  initialize variable y that assigns the value  0

p = 1 // initialize value 1 in the variable p which also known as starting position

init num = 1//define variable num that assign value 1

for j = 1 to n: //defining loop

y = m[j] - m[p]

if (y > 10) //defining if block

num++;  //increment num variable

p=i; //holding loop value in p variable

y= 0//assign value 0 in y variable

Explanation:

Following are the runtime analysis of the above-given algorithm:

The above-provided algorithm is greedy, but if it doesn't exceed the scope, it operates by greedily choosing its next object. Therefore the algorithm selects the fewest number of pens.

Running time:

This algorithm merely iterates once over all the points. The run-time is therefore O(n).

7 0
3 years ago
Will give brainliest
Alex73 [517]

Answer:

B

Explanation:

Im a 100% sure.

5 0
2 years ago
How do I logout of Brainly on mobile? When I went to settings, it had the option to log out but it was grayed out.
poizon [28]
Just delete the app
8 0
3 years ago
On the Format tab, in the Shape Styles group, there is the option to change the _____. a. Shape Effects b. Shape Fill c. Shape O
makvit [3.9K]
Hey there! Hello!

The answer to this problem will be D, "All Of The Above." I've attached a picture that shows the Shape Format tab in Microsoft Word. You can see in the dropdown that there's options for all three of your listed choices: Shape Fill, Shape Outline, and Shape Effects. 

I hope this helped you out! Feel free to ask me any additional questions if you have any. :-)

6 0
2 years ago
Other questions:
  • 3.What is deep focus, and when is it a good choice for a scene?
    8·1 answer
  • Suppose you are given a data set consisting of nominal attributes, such as color, which takes values such as red, blue, green et
    9·1 answer
  • Wearables, video playback and tracking devices can help athletes because
    15·1 answer
  • What happens when you apply a theme to a form?
    14·1 answer
  • Which of these lines of code will increment a variable?
    11·1 answer
  • Consider the following code.
    7·2 answers
  • The files in James's computer were found spreading within the device without any human action. As an engineer, you were requeste
    11·1 answer
  • Which tab on the ribbon in the folder window allows users to change how the contents of the folder are being shown?
    11·1 answer
  • Aii so is anyone pushing P?<br> if u are u a g
    8·2 answers
  • Calculate the time complexity for the following function in terms of Big O notation. Explain your answer.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!