Help with 6 programs
I am new at this forum, and am desperately looking for help with 6 very simple C programs. I am a total beginner and did some scratch work, but all the programs get way too many errors. I need to do a mandatory C-class, although I have never done this and am not a CS student. I would greatly, greatly, greatly appreciate your help :(.
1. Write a program that prints a table with each line giving an integer, its square, and its cube. Ask the user to input the lower and upper limits for the table. Use a for loop.
2. The ASCII value for a is 97. Ask the user to input the lower and upper limits for the table and make sure that the lower input is never below 32 and the upper limit is never above 127.
3. Write a program where you read a string from the keyboard. Print the string like this:
4. Write a program you can read up to 20 integers into an array. A negative value ends the input loop and the negative value is not part of the array. Then by using a switch statement, pressing a (and return) computes the average of the array (and prints the result), h prints the highest number in the array, l prints the minimal number in
the array, s prints the sum of all elements in the array and n prints the number of elements in the array. Use functions for each task. The result of these functions must be printed from the main() function.
Hint: The prototype to compute the average looks like this:
double compute_avg(int arr, int num);
5. Write a function int count_vowels(char str) that determines the number of vowels in a given string.
Then write a simple test program where you can repeatedly enter a string and then the number of vowels is determined and printed to the screen (from the main() function). If the entered string is empty (it will contain only an \n then) the program should quit.
6. Rewrite the function int count_vowels(char str) to walk the string using a pointer and address arithmetic. Reuse your test program from above.
God bless whoever could help me out.
Ooook... post your effort and we will help you with your errors.
( Why six? Couldn't it be seven? :D )
Heyy, that is what I have been given, 6 :-)
I have saved the programs in my class lab, so cannot access them at the moment unfortunately, I have to wait till tomorrow 2 PM (of West European time) till I can access it again and copy them, so I could only get back to you then...
Originally Posted by Salem