Question: 1. Write a program which generates all prime numbers between 2 and 20. [8 points 2. Write a program that counts the number of vowels
1. Write a program which generates all prime numbers between 2 and 20. [8 points 2. Write a program that counts the number of vowels (a, e, i, o, u) (or) (A, E, I, O, U) and the number of consonants in a sentence. [8 points] For example: Enter a sentence: And that's the way it is. Output: Your sentence contains 6 vowels. n! 3. Write a program to compute the permutations lp and combinations n! k!(n - k using recursive functions for the following three pairs of n and k: = c) (n, k) (7, 4). [9 points] 4. Write a program that calculates how many digits a number contains. Assume that the number has no more than four digits. [Hint: Use if statements to test the number.] [8 points] For example: Enter a number: 526 The number 526 has 3 digits. 5. Write a program that prompts the user to enter a telephone number in the form (xx) xx- xxxx and then displays the number in the form xxx.xxx.xxxx [7 points] For example: Enter phone number [(xxx) xxx-xxxx]: (404) 817-6900 You entered: 404.817.6900 Write a program to compute the sum and difference of two matrices which have the same order. Have the user enter the order of the matrices and then have the user enter the elements in the two matrices, and then perform addition and subtraction of respective elements. You may have to use for loops to obtain the entries of the two matrices and also may have to use for loops to add/subtract the entries. [Hint: All matrices have to be stored in 2-D arrays) [10 points] 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
