Hi all. I'm a n00b to programming. And I just started C in college. Unfortunately, the dude who's teaching us is going way too fast, and I don't understand anything he's teaching. He gave us an assignment a week after we started learning, and I can't do it. I've tried, I just can't seem to get any of the programs to work. Here are the questions, please, please help me out!
1) Write a program that will count from 1 to 12 and print the count, and its square, for each
2) Write a program that counts from 1 to 12 and prints the count and its inversion to 5 decimal
places for each count. This will require a floating point number.
3) Write a function that calculates the average of an array of 10 floating-point values and returns the result.
4) Prime numbers can be generated by an algorithm known as the Sieve of Erastosthenes. The algorithm for this procedure is presented here. Write a program that implements this algorithm. Have the program find all prime numbers up to 150.
Step 1. Define an array of integers P. Set all elements Pi to 0, 2 <= i <= n.
Step 2. Set i to 2.
Step 3. If i > n, the algorithm terminates.
Step 4. If Pi is 0, i is prime.
Step 5. For all positive integer values of j, such that i x j < n, set Pixj to 1.
Step 6. Add 1 to i and go to step 3.
5) Based on the following definitions
float f = 1.00;
short int i = 100;
long int l = 500L;
double d = 15.00;
and the seven steps outlined in this chapter for the conversion of operands in expressions, determine the type and value of the following expressions:
f + i
l / d
i / l + f
l * i
f / 2
i / (d + f)
l / (i * 2.0)
l + i / (double) l
6) Write a program that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in English. So, if the user types in 932, the program should display the following:
[b]nine three two[/b]
7) The factorial of an integer n, written n!, is the product of the consecutive integers 1 through n. For example, 5 factorial is calculated as follows:
5! = 5 x 4 x 3 x 2 x 1 = 1
Write a program to generate and print a table of the first 10 factorials.
8) Write a program that asks the user to type in two integer values at the terminal. Test these two numbers to determine whether the first is evenly divisible by the second, and then display an appropriate message at the terminal.
I seem to be able to do the 8th one. But the rest, I'm stuck. Please help!