Question

write a program that asks the User to enter a letter, then asks the user to...

write a program that asks the User to enter a letter, then asks the user to enter a sentence. the program will then print out how many time that letter occurred in the sentence. in C Language

Homework Answers

Answer #1
#include <stdio.h>

int main()
{
    char s[100], ch, temp;
    int i, count = 0;
    
    printf("Enter a letter: ");
    scanf ("%c", &ch);
    scanf ("%c", &temp);

    printf("Enter a sentence: ");
    scanf ("%[^\n]%*c", s);
    
    for(i = 0;s[i]!='\0';i++){
        if(s[i]==ch){
            count++;
        }
    }

    printf("%c occurred in the %s in %d times\n",ch,s,count);
    return 0;
}

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
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
Write a program that asks the user to enter an odd number and prints out a...
Write a program that asks the user to enter an odd number and prints out a triangle pattern. For example, if the user enters 5, the output is note: There is one space between the numbers in each line 1 3 5 1 3 1 If the user enters 9 the output is: 1 3 5 7 9 1 3 5 7 1 3 5 1 3 1 program language: C++
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Write a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
1. Write a code that asks the user to enter a sentence. Then process the sentence...
1. Write a code that asks the user to enter a sentence. Then process the sentence and let the user know which alphabets/numbers/symbols are used in the sentence and how many times. please use python
Q :     Write a C++ program that asks the user to enter three integers and...
Q :     Write a C++ program that asks the user to enter three integers and then displays the largest one. Example : if the user enter ( 7, 2 ,5) the largest number will be 7 Or if user enter ( 2 , 5 , 7 ) the largest number will be 7 Or if user enter ( 7, 5 ,2) the largest number will be 7 In general it does not matter the order of the entered numbers...
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”....
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”. If the user enters “bus” display “$1.00”. If they enter “subway” display “$1.50 and if they enter “walk” display “Free”. B. Write a java program that creates the following two arrays: String[] candidates = {“S Jones”,”Justin Fairfax”,”Clark Duncan”}; int[] votes = {7345,4324,3211}; Write the code that will search the votes array for the candidate with the largest number of votes and prints the name...
- Write a Python program which asks the user to enter a number, if the number...
- Write a Python program which asks the user to enter a number, if the number is divisible by 6 or 7, the program prints “The number X is divisible by 6 or 7” and if the number is neither divisible by 6 nor by 7, then it prints “The number X is not divisible by 6 and 7”.
asks the user for a word in the form of a string using matlab asks the...
asks the user for a word in the form of a string using matlab asks the user for a letter check to see if the letter is contained in the word if the letter is not contained, prints out sorry if the letter is contained print out the word
in c++ Write a program that asks the user for the speed of a vehicle (in...
in c++ Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. It should use a loop to display the total distance traveled. The speed traveled should be limited by the fastest speed achieved by a car thus far. Values should not be negative.•Ex: if hours = 3 and speed = 40, then the program should display•Hour 1: Distance Traveled: 40 miles•Hour 2: Distance Traveled: 80...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Emerald Co. uses a perpetual inventory system and records purchases of merchandise at net cost. The...
    asked 53 minutes ago
  • Movie stars and U.S. presidents have fished Pyramid Lake. It is one of the best places...
    asked 1 hour ago
  • what advantages do percent distributions have over frequency distributions when comparing populations at different years?
    asked 1 hour ago
  • Richard has just been given a 6-question multiple-choice quiz in his history class. Each question has...
    asked 1 hour ago
  • Write about westernized elements in life; westernization in our life, and this includes Americanization.
    asked 2 hours ago
  • The college Physical Education Department offered an Advanced First Aid course last summer. The scores on...
    asked 2 hours ago
  • Researchers hypothesized that increasing a woman's level of arousal would increase her perceptions of attractiveness of...
    asked 3 hours ago
  • Equation 37-14b in the textbook gives the energy emitted by Hydrogen when electrons transition between states...
    asked 3 hours ago
  • Theory of Computation Please provide explanation too on how it works a. Give an NFA recognizing...
    asked 3 hours ago
  • Question 1 A sequential pattern detection circuit (state machine) has input A and output Y, which...
    asked 3 hours ago
  • Natural Foods Inc. is planning to invest in new manufacturing equipment to make a new garden...
    asked 3 hours ago
  • Explain why a callable bond's price would be expected to decline less than an otherwise comparable...
    asked 4 hours ago