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
Ghella [55]
3 years ago
14

Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in

the string.
Ex: If the input is:

n Monday
the output is:

1
Ex: If the input is:

z Today is Monday
the output is:

0
Ex: If the input is:

n It's a sunny day
the output is:

2
Case matters.

Ex: If the input is:

n Nobody
the output is:

0
n is different than N.





This is what i have so far.
#include
#include
using namespace std;

int main() {

char userInput;
string userStr;
int numCount;

cin >> userInput;
cin >> userStr;

while (numCount == 0) {
cout << numCount << endl;
numCount = userStr.find(userInput);

}
return 0;
}
Computers and Technology
1 answer:
nevsk [136]3 years ago
5 0
Here is a Python program:

tmp = input().split(' ')
c = tmp[0]; s = tmp[1]
ans=0
for i in range(len(s)):
if s[i] == c: ans+=1

# the ans variable stores the number of occurrences
print(ans)
You might be interested in
The mac group does not replace the primary functions of eocs or other dispatch organizations. True or False
Oxana [17]

Answer:

TRUE

Explanation:

MAC - multi-agency coordination is a group of executives or administrators that have the authority to control agency funds or resources while EOCs -  Emergency operation centers are in charge of carrying out of emergency tasks that requires preparedness or disasters, they ensure that work continues even in case of emergency and disasters.

7 0
3 years ago
The function below takes a single parameter number_list which is a list that can contain integers and floats. Complete the funct
Andreas93 [3]

Answer:

  1. def getLargest(number_list):
  2.    new_list = []
  3.    for x in number_list:
  4.        if(isinstance(x, int)):
  5.            new_list.append(x)
  6.    largest = max(new_list)
  7.    return largest  

Explanation:

Firstly, create a function <em>getLargest()</em> that take one input parameter, <em>number_list</em>.

The function will filter out the float type number from the list by using <em>isinstance() </em>method (Line 5). This method will check if a current x value is an integer. If so, the x value will be added to <em>new_list</em>.

Next, use Python built-in <em>max</em> function to get the largest integer from the <em>new_list </em>and return it as output.

6 0
3 years ago
A mom is planning a theme park trip for her husband, herself, and their three children. The family has a budget of $500. Adult t
dolphi86 [110]

Complete question :

Sue is planning a theme park trip for her husband, herself, and her three children. She has a budget of $500. Adult tickets cost $55 each, and child tickets cost $25 each. Which formula should go in cell B4?

Answer:

=E1B1+E2B2

Explanation:

Cost of adult ticket = $55

Child ticket = $25

Number of adult = 2

Number of children = 3

Assume :

Cost of adult ticket = $55 = E1

Child ticket = $25 = E2

Number of adult = 2 = B1

Number of children = 3 = B2

The formula that should go into cell B5 in other to calculate total amount :

Total should be :

($55*2) + ($25*3)

=E1B1+E2B2

6 0
2 years ago
Does any body like animal jam
cricket20 [7]

Answer:

Never used it so I do not know.

Explanation:

To be honest i thought you meant like animal jelly at first

7 0
3 years ago
Read 2 more answers
This is more opinionated than question-based.
kozerog [31]

I think the Iphone is better the Google Pixels. That's just my opinion but some people like google pixels better.

7 0
3 years ago
Other questions:
  • Match the items.
    15·1 answer
  • Generate the requested sets using only set builder notation and the provided sets. Some problems may require you to build one or
    15·1 answer
  • Using either a UNIX or a Linux system, write a C program that forks a child process that ultimately becomes a zombie process. Th
    8·1 answer
  • 1. Extract title Write a function extract_title that takes one parameter, the filename of a GenBank formatted file, and returns
    14·1 answer
  • What type of Internet monitoring technique records information about a customer during a web surfing session, such as what websi
    8·1 answer
  • Logical design is tied to a specific hardware and software platform. a. True b. False
    9·1 answer
  • Problem: Mr. James Reid, the director of admissions at MOGCHS University, has
    14·1 answer
  • Hiiiiiiiiiiiiiiiiii <br>i'm new here!!!​
    14·2 answers
  • Your friends are having difficulties with their computer setups. Can you suggest a way to help each friend?
    5·1 answer
  • List and describe four services that comprise IT infrastructure, beyond physical devices and software applications.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!