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
HELP !!! Prompt <br> What is formatting text?
Svetach [21]

Answer:

Formatting text is how something is specifically layed out. Specific style.

Explanation:

7 0
2 years ago
Read 2 more answers
The grade of a metric bolt is designated by
Andre45 [30]
The answer to your question is The grade of a metric bolt is designated by the number stamped on the head of the bolt.
5 0
3 years ago
What is the magnitude of the largest positive value you can place in a bool? a char? an int? a float? a double??
Elena L [17]
The <span>magnitude of the largest positive value you can place in a bool, a char, an int, a float, a double are as follows:

</span><span>Int: 4 bytes Float: 4 double: 8 char: 1 boolean: 1
</span>
I hope my answer has come to your help. God bless and have a nice day ahead!
8 0
3 years ago
Choose the correct line of code.
Naddika [18.5K]
Def_pow_(self,b): if not then I’m sorry
5 0
3 years ago
2) What is the value stored in the variable z by the statements below?
Dmitriy789 [7]

Answer:

7

Explanation:

Because the q.length is a inbuilt function in the programming which used to get the length of the array. In the array, there are 7 values are store. Therefore, the size 7 store in the variable z.

For example:

int[] array={1,2};

int x = array.length;

the answer of above code is 2, because the elements present in the array is 2.

 

5 0
3 years ago
Other questions:
  • Which of the following is not an algorithm?
    8·1 answer
  • Rachel is on her way to an interview for the position of a project manager. She is trying to prepare for this interview by analy
    6·1 answer
  • True or False: You cannot change the default margin size for Word documents.  
    6·1 answer
  • Write a program that responds to a positive integer passed on the command line with the number of bits needed to express that nu
    10·1 answer
  • An Administrator wants to have a thank you email sent after the form on the "Request a Demo" landing page is submitted. Where ca
    12·1 answer
  • Radar devices are used by law enforcement to be sure that individuals are driving safely. They tell the officer how fast the veh
    12·1 answer
  • How has your perspective changed since the beginning of the class?
    5·1 answer
  • Chantelle wants to change the color scheme for her company's web app, and she needs to get the logos updated. What kind of devel
    8·1 answer
  • Radio spectrum is the part of the complete range of electromagnetic waves that is used for radio communication from
    14·1 answer
  • What are good reasons to do yearly disaster recovery testing? check all that apply
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!