Question 1: Read in two positive integers, m and n, and output the smallest prime number p larger than m where the sum of the digits of p is larger than n.
Question 2: Without using math.h, read in three positive integers k, r, and n, and output the kth digit of the rth root of n.
Question 3: For this problem, you may not use math.h,
and you may only use the following facts about the functions sin(x) and
cos(x) when computing your answer:
sin(0) = 0, sin(30) = 1/2, sin(45) = sqrt(2)/2,
and sin(60) = sqrt(3)/2.
sin2(x) + cos2(x) = 1
sin(a+b) = sin(a)cos(b) + cos(a)sin(b)
cos(a+b) = cos(a)cos(b) - sin(a)sin(b)
sin(-x) = sin(x), cos(-x) = cos(x)
Now, again using only the rules above, read in an integer d and output
sin(d) and cos(d) separated by a comma. Note that you will only receive
inputs which can be correctly computed using these rules.
Question 4: We will define a simple word as having three letters: an uppercase consonant, a lowercase vowel, and a lowercase consonant. 'Y' is always a consonant. The value of a word is the sum of the ASCII values of its letters. Write a program which takes no input and prints out the number of simple words whose value is prime. Note that your program must compute the answer, and not just print it out directly.
Question 5: Read in positive integer k and digit d (so 0 <= d <= 9), and output the smallest prime with at least k d's.
Question 6: Read in positive decimal integers n, b, and k, where (2 <= b <= 36), and output the kth digit of n in base b. Use capital letters for digits larger than 9.
Question 7: Read in a line of text (terminated
with end of line, which is not part of the input). You have a robot
which begins at (0,0). Read left to right, each character in the
input tells the robot to move one step in some direction, according to
the following rules:
1. if the ascii value of the character is prime, move right.
2. if the character is a vowel, move down.
3. if the character is in the first half of the alphabet (case insensitive,
[a,m]), move up.
4. move left.
Note that for each character the robot only applies the lowest numbered
rule that applies, and that rule 4 always applies so some move always occurs.
Output the final location of the robot, (x,y).
Question 8: Repeatedly read in a line of text (terminated with end of line, which is not part of the input), terminating your program when a blank line is entered. For each line, output "YES" if the line is a palindrome (same backwards as forwards), or "NO" otherwise, followed by a newline.
Question 9: Read in a line of text (terminated with end of line, which is not part of the input), and output "YES" if it has matching parentheses, and "NO" otherwise. To have matching parentheses, every left paren must have a matching right paren to its right, and every right paren must have a matching left paren to its left.
Question 10: Write a program which finds the single-digit numbers a, b, c, and d such that abcd = abcd. Output the 4-digit number abcd. Note that your program must compute the answer, and not just print it out directly.
Question 11: Write a program which reads in a string representing a valid Roman Numeral between 1 and 3000. Output the number in decimal. Note that I=1, V=5, X=10, L=50, C=100, D=500, and M=1000. Also note that a lesser number to the left of a greater number is subtracted, so IX = 10 minus 1 = 9.
Question 12: Here we investigate an illegal math operation: dividing ab by bc by eliminating the b's, so that we get ab/bc = a/c. Now it turns out that this actually works for some a,b,c, such as 1,9,5: 19/95 = 1/5. Assume that none of a, b, or c is 0. Write a program which prints out all combinations of a,b,c which this trick works for, followed by the total number of such combinations. Note that your program must compute the answer, and not just print it out directly.
Question 13: Read in a list of words, one
per line, terminated with the word "_end_" which is only a sentinel (and
so is not part of the input), and output the word which has the highest
ratio of consonants to vowels, where 'y' is always a consonant.