Question

In: Computer Science

Write a C program named as listLetterFreq.c that lists the frequency of the letters from the...

Write a C program named as listLetterFreq.c that lists the frequency of the letters from the input via ignoring the case sensitivity. For example, sample outputs could be like below.

Please input a string:

This is a list of courses. CSC 1010 - COMPUTERS & APPLICATION

Here is the letter frequency:

Letter a or A appears 3 times

Letter b or B appears 0 times

Letter c or C appears 5 times

Letter d or D appears 0 times

Letter e or E appears 2 times

Letter f or F appears 1 times

Letter g or G appears 0 times

Letter h or H appears 1 times

Letter i or I appears 5 times

Letter j or J appears 0 times

Letter k or K appears 0 times

Letter l or L appears 2 times

Letter m or M appears 1 times

Letter n or N appears 1 times

Letter o or O appears 4 times

Letter p or P appears 3 times

Letter q or Q appears 0 times

Letter r or R appears 2 times

Letter s or S appears 8 times

Letter t or T appears 4 times

Letter u or U appears 2 times

Letter v or V appears 0 times

Letter w or W appears 0 times

Letter x or X appears 0 times

Letter y or Y appears 0 times

Letter z or Z appears 0 times

Solutions

Expert Solution

C PROGRAM ====>

#include <stdio.h>

int main() {
char str[1000]; // max size is 1000


printf("Enter a string: ");
fgets(str, sizeof(str), stdin);

char str1[] = "abcdefghijklmnopqrstuvwxyz"; // alphabets in small letter
char str2[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // alphabets in capital letter


for(int i=0;i<26;i++)
{
int count=0;
for (int j = 0; str[j] != '\0'; ++j)
{
if (str1[i] == str[j] || str2[i] == str[j]) // compare character of str with str1 and str2
{
++count;
}
}
printf("Letter %c or %c appears %d times\n",str1[i],str2[i],count);
}

return 0;
}

OUTPUT SCREENSHOT ===>


Related Solutions

In a c programming Write a program that converts upper case letters to lower case letters...
In a c programming Write a program that converts upper case letters to lower case letters or vice versa: Enter a sentence: What a GREAT movie is! Converted sentence: wHAT_A_great_MOVIE_IS_ Convert all non-alphabetical letters to ‘_’
C LANGUAGE ONLY Write a C program to count the frequency of each element in an...
C LANGUAGE ONLY Write a C program to count the frequency of each element in an array. Enter the number of elements to be stored in the array: 3 Input 3 elements of the array: element [0]: 25 element [1]: 12 element [2]: 43 Expected output: The frequency of all elements of an array: 25 occurs 1 times 12 occurs 1 times 3 occurs 1 times
How do I write a C++ program to call a frequency table from a csv file,...
How do I write a C++ program to call a frequency table from a csv file, using vector? Data given is in a csv file. Below is part of the sample data. Student ID English Math Science 100000100 80 90 90 100000110 70 60 70 100000120 80 100 90 100000130 60 60 60 100000140 90 80 80
C++ Write a program that lets the user enter a two letters which are f and...
C++ Write a program that lets the user enter a two letters which are f and s with a length of 5. And outputs how many times it was occurred and lists the 2 most repeating pattern with 5lengths of f and s. The output display should always start at three-f(s) .Include an option where user can retry the program. Example: Input: sssfsfsfssssfffsfsssssfffsffffsfsfssffffsfsfsfssssfffffsffffffffffffssssssssfffsffffsssfsfsfsfssssfffsssfsfsffffffssssssffffsssfsfsfsss Output: The most repeating 5lengths of pattern is: fffsf and occurred 6times. Output2: The second most repeating...
using C# Write a program named RectangleArea tocalculate the area of a rectangle with a...
using C# Write a program named RectangleArea to calculate the area of a rectangle with a length of 15.8 and a width of 7.9. The program should have two classes, one is theRectangleArea holding the Main(), and the other one is Rectangle. The Rectangleclass has three members: a property of length, a property of width, and a method with a name of CalArea() to calculate the area. You can invoke the auto-provided constructor or write a self-defined constructor to initialize...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an empty main function, then add statements in main() to accomplish each of the tasks listed below. Some of the tasks will only require a single C++ statement, others will require more than one. For each step, include a comment in your program indicating which step you are completing in the following statement(s). The easiest way to do this is copy and paste the below...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an...
Write a C++ program that start the assignment by creating a file named pointerTasks.cpp with an empty main function, then add statements in main() to accomplish each of the tasks listed below. Some of the tasks will only require a single C++ statement, others will require more than one. For each step, include a comment in your program indicating which step you are completing in the following statement(s). The easiest way to do this is copy and paste the below...
USING C++ PLEASE Write a program named Lab11C that calculates the average of a group of...
USING C++ PLEASE Write a program named Lab11C that calculates the average of a group of test scores where the lowest score is dropped. It should use the following functions a) void getScores should have 4 double reference parameters (one for each test score) getScores should do the following: - read 4 test scores from the text file Lab11C.txt (Important: declare your ifstream infile and open the file inside this function, not in the main function) - store them in...
Write a script named numberlines.py. This script creates a program listing from a source program. This...
Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the user for the names of two files. The input filename could be the name of the script itself, but be careful to use a different output filename! The script copies the lines of text from the input file to the output file, numbering each line as it goes. The line numbers should be right-justified in 4 columns, so that the...
write a program in c++ to design a tuning circuit for a given frequency bond using...
write a program in c++ to design a tuning circuit for a given frequency bond using a variable capacity to determine the value of an inductance required for a given frequency range
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT