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

      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
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,...
I need this in C# with pseudocode Exercise #2: Design and implement a programming (name it...
I need this in C# with pseudocode Exercise #2: Design and implement a programming (name it EvenOdd) that uses a while loop to determine and print out all even numbers between 50 and 100 on a single line, separated by commas. Then another while loop in the same program to print out all odd numbers between 50 and 100 on a new line, separated by commas. Document your code and properly label the outputs as shown below. Even numbers between...
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])
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...
1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any...
1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any positive integer n, it will print out the sum of the squares from 1 to n. For example given 3 the algorithm will print 14 (because 1 + 4 + 9 =14) You can use multiplication denoted as * in your solution and you do not have to define it (For example. 3*3=9) For example if n is 6 it will print: The sum...
Pseudocode and algorithm of finding median of unordered array in linear time.
Pseudocode and algorithm of finding median of unordered array in linear time.
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]
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT