Question

how to find the size of the words and does it match the number value 2...

how to find the size of the words and does it match the number value

2 lines with a word and a number on each

Ex:

Tennis 2

Ball 4

how do you iterate through each line to find the size and if it matches up to the number? (c++)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <string>

using namespace std;

int main()
{
int wSize;
string usrWord;
getline(cin, usrWord,' ');
cin>>wSize;

if( usrWord.size() == wSize)
cout<<"Both the user input size and the actual word size are same\n";
else
cout << "Both the sizes are not equal\n";
}

Add a comment
Know the answer?
Add Answer to:
how to find the size of the words and does it match the number value 2...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I thought the answer was C) 5 but that is incorrect. I am not sure how to find the correct answer. 25. In many women's tennis matches they play best-out-of-three sets. In other words, they pla...

    I thought the answer was C) 5 but that is incorrect. I am not sure how to find the correct answer. 25. In many women's tennis matches they play best-out-of-three sets. In other words, they play until one player wins two sets, and there are no ties. Lourdes and Mariana are two rivals, though Lourdes seems to win about six sets for every four that Mariana wins. Use the random numbers table below to simulate 10 matches between Lourdes and...

  • To further enhance discussion, how would you specify the size of a ROM (number of words...

    To further enhance discussion, how would you specify the size of a ROM (number of words and number of bits per word) that will accommodate the truth table for the combinational circuit components of a binary multiplier that multiplies two 4‐bit binary words?

  • Problem 1.0-20 Points A certain memory has a word size of 8K x 32. How many words does it store? ...

    Problem 1.0-20 Points A certain memory has a word size of 8K x 32. How many words does it store? What is the number of bits per word? How many memory cells does it contain? Problem 1.0-20 Points A certain memory has a word size of 8K x 32. How many words does it store? What is the number of bits per word? How many memory cells does it contain?

  • ** Language Used : Python ** PART 2 : Create a list of unique words This...

    ** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...

  • Please complete the following: Write a Python script to do the following: 1. Ask the use...

    Please complete the following: Write a Python script to do the following: 1. Ask the use to enter several sentences, one at a time in a loop). To end the sentence entry, the user enters a blank (empty) sentence. 2. Extract each word from each sentence and put it in a list. This will require at least one loop to go through each sentence in the list. It is up to you how you want to get the words in...

  • 1) The following memory unit is specified by the number of words times the number of...

    1) The following memory unit is specified by the number of words times the number of bits per word: 4 TB x 8. *How many address lines and input-output data lines are needed in each case? *Give the number of bytes stored in this memory

  • 1. How do UPGMA and NJ similar? 2. How does the BLAST algorithm work? What is...

    1. How do UPGMA and NJ similar? 2. How does the BLAST algorithm work? What is a ‘word’? How are words derived from the input (query) sequence? Once words are identified from the input, what is searched? How does BLAST extend a match? 3. How do BLOSUM and PAM compare? What’s similar between the two? What’s different? How do sequence search algorithms (e.g., BLAST) and transition matrices (e.g., BLOSUM and PAM) relate?

  • c program that counts the number of characters, words and lines from standard input until EOF....

    c program that counts the number of characters, words and lines from standard input until EOF. attached is what i Have so far but its not working ?. about shell redirection Requirements 1. Write a C program that counts the number of characters, words and lines read from standard Input until EOF Is reached. 2. Assume the Input is ASCII text of any length. 3. Every byte read from stdin counts as a character except EOF 4. Words are defined...

  • The file ‘classes.txt’ contains an unknown number of lines. Each line contains two words. The first...

    The file ‘classes.txt’ contains an unknown number of lines. Each line contains two words. The first word is the course number (‘CS021’, for example) and the second word is the instructor’s last name (Eddy). There are no duplicate courses in the file. On the other hand, an instructor may teach more than one course. Write a code segment that opens the file, loads the key/value pairs into a dictionary and then closes the file. No documentation or exception handling is...

  • a) A memory unit has 28-bit address lines and 64-bit input/output data lines. How many bytes...

    a) A memory unit has 28-bit address lines and 64-bit input/output data lines. How many bytes of data can this memory hold? How many words does it contain, and how large is each word? b) A memory unit consists of 32M words of 16-bit each. How many bits wide address lines and input-output data lines are needed to access this memory? c) A memory unit consists of 512K bytes of data. How many bits wide address lines are needed to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT