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
What is the difference between a Is your Milling machine and grinding machine
Law Incorporation [45]

Answer:

one is used for milling and one is used for grinding

Explanation:

8 0
2 years ago
Michael is stuck due to an electric shock generated at the fridge. What should you do to save michael?.
NISA [10]

Pull him away from the fridge with a non-conducting material and begin cardiopulmonary resuscitation .

<h3>What is meant by electric shock?</h3>

When a human comes into contact with an electrical energy source, they experience an electric shock. A shock is produced when electrical energy passes through a section of the body. Exposure to electrical energy has the potential to cause fatalities or absolutely no injuries.

The tangible and tangible result of an electrical current entering the body is electrical shock. The shock could be anything from a dangerous discharge from a power line to an uncomfortable but safe jolt of static electricity after walking over a thick carpet on a dry day. trauma; related topics.

The complete question is : Michael is stuck due to an electric shock generated at the fridge. What should you do to save Michael?

A. push the fridge away with a non-conducting material and begin cardiopulmonary resuscitation

B. push the fridge away from him and begin cardiopulmonary resuscitation

C. pull him away from the fridge with a non-conducting material and begin cardiopulmonary resuscitation

D .pull him away from the fridge with your hands and begin cardiopulmonary resuscitation

To learn more about electric shock refer to:

brainly.com/question/28361869

#SPJ1

7 0
1 year ago
Which of the following was not important in the development of the internet?
lesantik [10]
D. Rise of NASA.Hope I helped.
8 0
3 years ago
Read 2 more answers
To save a document with a new name, click _______ in the navigation bar and enter a new filename.
cricket20 [7]
Click the save as button
3 0
3 years ago
Using MARS/MIPS
slega [8]

Answer:

Explanation:

MIPS program which increments from 0 to 15 and display results in Decimal on the console

In this program the user defined procedures print_int and print_eot were used to print the integer values and new line characters(\n) respectively.the mechanisam of the loop is explaine in the comment section of the program.

     addi $s0, $0, 0

     addi $s1, $0, 15

print_int:

              li $v0, 1                # system call to print integer

              syscall                

              jr $ra                     # return

print_eol:                      # prints "\n"

            li $v0, 4            

              la $a0, linebrk      

              syscall              

              jr $ra                  # return

main: . . .          

              li $a0, 0                # print 0

              jal print_int         # print value in $a0

loop:   move $a0, $s0           # print loop count

       jal print_int        

       jal print_eol           # print "\n" character

       addi $s0, $s0, 1        # increment loop count by 1

       ble $s1, $s0, loop      # exit if $s1<$s0

beq $s0, $0, end

end:

MIPS progam to increment from 0 to 15 and display results in Hexadecimal on the console

this program is slightly differed from the previous program in this program the system call issued in print_int is implemented with a system call that prints numbers in hex.

addi $s0, $0, 15

     addi $s1, $0, 0

print_int:

   li      $v0,34                  # syscall number for "print hex"

   syscall                         # issue the syscall

              jr $ra                     # return

print_eol:                      # prints "\n"

            li $v0, 4            

              la $a0, linebrk      

              syscall              

              jr $ra                  # return

main: . . .          

              li $a0, 0                # print 0

              jal print_int         # print value in $a0

loop:   move $a0, $s0           # print loop count

       jal print_int        

       jal print_eol           # print "\n" character

       addi $s0, $s0, 1        # increment loop count by 1

       ble $s1, $s0, loop      # exit if $s0>$s1

beq $s0, $0, end

end:

5 0
3 years ago
Other questions:
  • Danielle, a help desk technician, receives a call from a client. In a panic, he explains that he was using the Internet to resea
    8·1 answer
  • 9.1.3: Printing vector elements with a for loop. Write a for loop to print all NUM_VALS elements of vector courseGrades, followi
    5·1 answer
  • What happens if you have you an image that has 6 bits-per-pixel and you change it to 12
    6·1 answer
  • Jack used primarily web sources for his informative speech about gun control. however, his over-reliance on the web site sponsor
    11·1 answer
  • Which model represents any process in general?
    6·1 answer
  • Draw a flowchart or write pseudocode to represent a program's logic that allows the user to enter a value. The program multiplie
    5·1 answer
  • Product of -6/13 and reciprocal of -7/16 is ____________​
    7·1 answer
  • Who is famous for his three laws of robotics?
    9·1 answer
  • 1. Sunday Times wants an analysis of the demographic characteristics of its readers. The
    8·1 answer
  • Question 1
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!