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
_______________ provides options for getting access to your old password or resetting the account to a temporary password; users
gtnhenbr [62]

Answer:

account recovery

Explanation:

account recovery, provides options for getting access to your old password or resetting the account to a temporary password; users will change to a permanent password upon first login.

3 0
2 years ago
How would I copy this image?
Dahasolnce [82]

Question: <em>How would I copy this image?</em>

Answer: Either screenshot it, or CTRL C ± CTRL V it. To screenshot something, open 'snipping tool' and pull up the PDF, then box in whatever you are trying to copy. You can also reverse image search it to find it somewhere on the web.

Uplifting Note: To you, smiling at someone may mean nothing, but to them, it might be their whole world.

3 0
3 years ago
Technician A says that oil for the rod bearings comes from splash off the crankshaft. Technician B says that lubrication to the
worty [1.4K]

Answer: technician B

Explanation:

The oil is picked up from the oil pump though a pick up tube that is mounted on the oil pump. The end of the pick up tube sits in the oil at the bottom of the oil pan. The oil is then forced through holes that are drilled into the block. Those holes which are called (journals) lead to the main bearings,rod bearings,lifters, camshaft, ect..

7 0
3 years ago
Lesser-known ideas and interpretations of common knowledge need to be documented. true or false.
Tresset [83]
False. As it is common knowledge, it is unnecessary for it to be documented.
7 0
3 years ago
____ ensures that the network does not become saturated at any one poin
Tcecarenko [31]
The answer is a network layer. It prevents saturation since it manages and distributes data. It serves as a control to all other networks that receives data. The main function is to create, end or reserve connections by identifying and recognizing IP addresses of connected networks.  
5 0
3 years ago
Other questions:
  • 2 negative impact of excessive use of computer even in solving mathematical problem.
    11·1 answer
  • What type of organizational structure would you want to use for this company (by function, by process, by product, and so on)? E
    11·1 answer
  • 5. How would you describe the relationship between blocks of code and commands?​
    14·2 answers
  • Consider the following method, which is intended to return the index of the first negative integer in a given array of integers.
    14·1 answer
  • In a non-price rationing system, consumers receive goods and services first-come, first served. Give me an example of a time whe
    8·1 answer
  • Which of the following component is required to insert text in multimedia
    8·1 answer
  • List and explain three computing devices from the 20th century​
    13·2 answers
  • Dominic list his camera for sale on an online auction site Chloe is the highest bitter and purchase as the camera how does the a
    14·1 answer
  • ____allow(s) visually impaired users to access magnified content on the screen in relation to other parts of the screen.
    5·1 answer
  • What are some of the most common obstacles in video games?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!