Question

In: Computer Science

Design an algorithm ( pseudocode or C ) to calculate the frequency of each of the...

Design an algorithm ( pseudocode or C ) to calculate the frequency of each of the vowels (lowercase and uppercase) in a text. The program will ask the user for a text, which will be entered by keyboard and will save, in a table (in%), the frequency of each of the vowels within the text, taking into account all the characters of the text. The text will end with the character '' # ''. Includes the emty sequence.

Solutions

Expert Solution

//Required program in c

#include<stdio.h>
void main()
{
   char arr[1000][1000];
   int i,j,l,c[10];
   for(i=0;;i++)
       {      
       for(l=0;l<10;l++)c[l]=0;
           for(j=0;;j++)
               {
                   scanf("%c",&arr[i][j]) ;
                   if(arr[i][j]!='#'&&arr[i][j]!='\n'&&arr[i][j]!='\0'){
                       if(arr[i][j]=='a')c[0]++;
                       if(arr[i][j]=='A')c[1]++;
                       if(arr[i][j]=='e')c[2]++;
                       if(arr[i][j]=='E')c[3]++;
                       if(arr[i][j]=='i')c[4]++;
                       if(arr[i][j]=='I')c[5]++;
                       if(arr[i][j]=='o')c[6]++;
                       if(arr[i][j]=='O')c[7]++;
                       if(arr[i][j]=='u')c[8]++;
                       if(arr[i][j]=='U')c[9]++;
                   }
                   else{
                       printf("a = %d, ",c[0]);
                       printf("A = %d, ",c[1]);
                       printf("e = %d, ",c[2]);
                       printf("E = %d, ",c[3]);
                       printf("i = %d, ",c[4]);
                       printf("I = %d, ",c[5]);
                       printf("o = %d, ",c[6]);
                       printf("O = %d, ",c[7]);
                       printf("u = %d, ",c[8]);
                       printf("U = %d\n",c[9]);
                       break;
                   }
               }
               if(arr[i][j]=='\n'||arr[i][j]=='\0')break;
          
          
       }
  
}


Related Solutions

Problem 1: (10 marks) ALGORITHM COMPLEXITY:Write an algorithm (pseudocode but not a program) that takes a...
Problem 1: ALGORITHM COMPLEXITY:Write an algorithm (pseudocode but not a program) that takes a positive numberias an input, where i=a1a2...an,n>=3(numberwith 3 or more digits, every digit can have the value between 0 and 9–both inclusive). The algorithm should find the largest number jsuch that j=b1..bm, 1<=m<=n(numberwith m digits),andevery bk<=bk+1where1<=k<m and bk,bk+1ε{a1, a2, an}.Also, perform the computational complexity (time complexity)analysis of your algorithm and write the algorithm complexity in Big-Oh notation. Examples:Input: 23720, Output: 237Input: 9871, Output: 9Input: 1789, Output:1789Input: 2372891,...
Implement the following pseudocode in Python Consider the following pseudocode for a sorting algorithm: STOOGESORT(A[0 ......
Implement the following pseudocode in Python Consider the following pseudocode for a sorting algorithm: STOOGESORT(A[0 ... n - 1]) if (n = 2) and A[0] > A[1] swap A[0] and A[1] else if n > 2 m = ceiling(2n/3) STOOGESORT(A[0 ... m - 1]) STOOGESORT(A[n - m ... n - 1]) STOOGESORT(A[0 ... m - 1])
      Design an algorithm for each of the exercises and type it into a word document....
      Design an algorithm for each of the exercises and type it into a word document. Upload the document to PE1 assignment folder. The roots of quadratic equation: Design an algorithm to find the real roots of a quadratic equation of the form ax2+bx+c=0, where a, b, c are all real numbers and a is nonzero
LargestTwo problem: Based upon the pseudocode code below, implement in C++ a divide-and-conquer algorithm that finds...
LargestTwo problem: Based upon the pseudocode code below, implement in C++ a divide-and-conquer algorithm that finds the largest and second largest value from a vector of ints. void LargestTwo (vector l, int left, int right, int & largest, int & secondLargest) • Please write comment for your functions, similar to the one in the pseudocode, to include both pre- and post-conditions. • Comment on the logic of your code, e.g., what is true after the two recursive calls? • Answer...
Without using Pivot Tables, calculate the Frequency, Relative Frequency, and Percent Frequency for each major. Major...
Without using Pivot Tables, calculate the Frequency, Relative Frequency, and Percent Frequency for each major. Major ECON BIOL CHEM CHEM MKTG CHEM ACCT CHEM MGMT BIOL BIOL IBUS CHEM ACCT FINA CHEM MKTG CHEM PHYS ECON PHYS ECON MKTG ACCT MATH IBUS MATH MGMT ACCT ECON BIOL CHEM PHYS MGMT ACCT ACCT CHEM PHYS ECON ACCT MGMT ECON MGMT MATH ACCT MATH MGMT MATH FINA ACCT CHEM MGMT ECON ECON FINA IBUS MGMT FINA MGMT CHEM ACCT ACCT IBUS MKTG...
Pseudocode and algorithm of finding median of unordered array in linear time.
Pseudocode and algorithm of finding median of unordered array in linear time.
write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
IN C++ LANGUAGE PLEASE::: Distance calc. This question is fairly straightforward. Design (pseudocode) and implement (source...
IN C++ LANGUAGE PLEASE::: Distance calc. This question is fairly straightforward. Design (pseudocode) and implement (source code) a program to compute the distance between 2 points. The program prompts the user to enter 2 points (X1, Y1) and (X2, Y2). The distance between 2 points formula is: Square_Root [(X2 – X1)^2 + (Y2 – Y1)^2]
Consider the following pseudocode for insertion-sort algorithm. The algorithm sorts an arbitrary array A[0..n − 1]...
Consider the following pseudocode for insertion-sort algorithm. The algorithm sorts an arbitrary array A[0..n − 1] of n elements. void ISORT (dtype A[ ], int n) { int i, j; for i = 1 to n – 1 {     //Insert A[i] into the sorted part A[0..i – 1]     j = i;     while (j > 0 and A[j] < A[j – 1]) {         SWAP (A[j], A[j – 1]);         j = j – 1 }     }...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the following requirements: Reads in a series of positive integers,  one number at a time;  and Calculate the product (multiplication) of all the integers less than 25,  and Calculate the sum (addition) of all the integers greater than or equal to 25. Use 0 as a sentinel value, which stops the input loop. [ If the input is 0 that means the end of the input list. ]...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT