Question

Please write code in c++ using iostream library. Write a function that have to copy one...

Please write code in c++ using iostream library.

Write a function that have to copy one char array to other avoiding any not-letter symbols, program have to use pointer.

Input:
First line contains sequence of chars (size is not more that 100).

1w[a3ter11

output: water

Homework Answers

Answer #1

#include <iostream>

using namespace std;

int main()

{

    // input character array

    char input[1000];

    // read input

    cin >> input;

    // copy to output array

    char output[1000];

    int i = 0, j = 0;

    // till end of input

    while (input[i] != 0)

    {

        // if current character is uppercase or lowercase letter

        if ((input[i] >= 'a' && input[i] <= 'z') || input[i] >= 'A' && input[i] <= 'Z')

            output[j++] = input[i];

        i++;

    }

    // append null

    output[j] = 0;

    // print output

    cout << output;

}

.

Output:

.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Matrix Multiplication with Threads - C/C++ **Read entire question before answering** **Don't copy / paste code...
Matrix Multiplication with Threads - C/C++ **Read entire question before answering** **Don't copy / paste code without testing it. I will downvote your answer and mark as spam.** I have posted this question several times, do not copy / paste the same code that has been posted, IT DOESN'T WORK!! In this assignment you will use the Pthreads library to write a program that multiplies two square arrays and compare the difference between the imperative and parallel implementations of this...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER QUESTION: 1) Fibonacci sequence is a sequence in which every number after the first two is the sum of the two preceding ones. Write a C++ program that takes a number n from user and populate an array with first n Fibonacci numbers. For example: For n=10 Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 2): Write...
USING JAVA: I was asked to write a function that obtains a name from the user...
USING JAVA: I was asked to write a function that obtains a name from the user and returns it in reverse order (So if the user inputs "MIKE" the function returns "EKIM"). You can't use string variables it can only be done using a Char Array. Additionally, you can use a temporary Char Array but you are supposed to return the reverse order in the same char array that the user input, this is for hypothetical cost purposes -we are...
in C++ Need a heap-sort function #include <iostream> #include <stdlib.h> #include <string> using namespace std; void...
in C++ Need a heap-sort function #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc ( int *array ) { // Your code here ----------------- } int main(int argc,char **argv) { int *Sequence; int arraySize; // Get the size of the sequence cin >> arraySize; // Allocate enough memory to store "arraySize" integers Sequence = new int[arraySize];    // Read in the sequence for ( int i=0; i<arraySize; i++ ) cin >> Sequence[i]; // Run your algorithms to...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total 52 case sensitive) and five special characters (‘.’, ‘,’, ‘:’, ‘;’ and ‘!’) in all the .txt files under a given directory. The program should include a header count.h, alphabetcount.c to count the frequency of alphabet letters; and specialcharcount.c to count the frequency of special characters. Please only add code to where it says //ADDCODEHERE and keep function names the same. I have also...
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++ 11. Write a function that will merge the contents of two sorted (ascending order) arrays of type double values, storing the result in an array out- put parameter (still in ascending order). The function shouldn’t assume that both its input parameter arrays are the same length but can assume First array 04 Second array Result array that one array doesn’t contain two copies of...
Quick sort func in C++ #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc...
Quick sort func in C++ #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc ( int *array ) { // Code here } int main(int argc,char **argv) { int *Sequence; int arraySize; // Get the size of the sequence cin >> arraySize; // Allocate enough memory to store "arraySize" integers Sequence = new int[arraySize];    // Read in the sequence for ( int i=0; i<arraySize; i++ ) cin >> Sequence[i]; // Run your algorithms to manipulate the elements...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter 10 numbers. 2. save those numbers in a 32-bit integer array. 3. Print the array with the same order it was entered. 3. Calculate the sum of the numbers and display it. 4. Calculate the mean of the array and display it. 5. Rotate the members in the array forward one position for 9 times. so the last rotation will display the array in...
Write code in JAVA Write a program that will output a right triangle based on user...
Write code in JAVA Write a program that will output a right triangle based on user specified input height (int) and specified input symbol (char).The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches specified input height. Output a space after each user-specified character, including after the line's last user-specified character. Hint: Use a nested for loop. Ex:If the input...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Write an M-File scripts that converts temperature in degrees Fahrenheit ( °F) to degrees Centigrade (...
    asked 2 minutes ago
  • Two spherical soap bubbles in air (with local pressure P0) come into contact and fuse to...
    asked 2 minutes ago
  • determine the combination of alkaline earth cations and test solution anions that produce a precipitate. Predict...
    asked 6 minutes ago
  • Homework of Unit Three 1. Situational Writing Situation: Value Link Co.,Ltd.(Add.:27 Srinakarin street,Bangkok,Thailand, Zip:10250, Fax:66-02-330-9765), deals...
    asked 17 minutes ago
  • Rothamsted Experimental Station (England) has studied wheat production since 1852. Each year, many small plots of...
    asked 26 minutes ago
  • 51. Which of the following type of dementia is the most common among all dementias A.Parkinsons...
    asked 27 minutes ago
  • A mad physicist assembled an EM wave generator. He claims that the generator is able to...
    asked 30 minutes ago
  • Question # 3: Solve the following conversions: a. %01000101 = ? (Decimal) b. 24510 = %____________...
    asked 43 minutes ago
  • 5. The Scientist-Practitioner model A. Focuses on the objective assessment of data only B. Focuses on...
    asked 46 minutes ago
  • 7) A disk is initially spinning about its center at 18 rad/s counter-clockwise and a constant...
    asked 46 minutes ago
  • -Two restaurants, Epicurean Eats and Dino’s Diner, operate in the same neighborhood. Epicurean Eats is a...
    asked 53 minutes ago
  • 1.What is the discount rate assuming the present value of $840 at the end of 1-year...
    asked 1 hour ago