CSP2151 Workshop 3 Assignment
Edith Cowan University School of Science
CSP2151 Workshop 3
Design the following:
- Write a function int_max_3 that takes three int arguments and returns the largest of them as the value of the function.
- The function islower() returns true if its int argument is a lowercase character. Write your own version of islower() called myislower().
- Write your own version of toupper(), also in ctype.h, which converts lowercase letters to uppercase letters, and leaves all other characters unchanged. Bonus (no assistance on this one!):
- Write a function int logstar(double) that calculates this function.
log x * {1 + log * (log2x) if x ≤ 1 otherwise
Design and Implement the following:
- Write a function cube_root that receives a double argument and calculates and returns an approximate cube root for it. You should also write a main program that allows you to test your function.
- Write a function that reads integers until it obtains one in the range given by its first two arguments. When a suitable value is read, it stores that value using its third argument, and returns the predefined constant READ_OK . If no suitable value is located, the predefined constant READ_ERROR should be returned.
Assessable:
1) Design with either pseudocode or flowcharts and extend your previous lunar lander program to do the following:
You are now to use two functions:
float Delta_V(float, int, float*) takes the velocity, thrust and a pointer to the altitude of the lander capsule as arguments, calculates the new velocity, modifies the altitude pointer to the new height and then returns the new velocity.
int Check_Status(float, float) takes the velocity and altitude of the lander capsule and checks to see what the status of the module is. If the capsule is still falling it should return 0. If the capsule has landed it should return 1. If the capsule has crashed it should return 2.
Triangular numbers are used to describe the pattern of dots that form larger and larger triangles. The sequence can also be described as:
0 | + | 1 | = | 1 |
1 | + | 2 | = | 3 |
3 | + | 3 | = | 6 |
6 | + | 4 | = | 10 |
2) Design with either pseudocode or flowcharts , using either pseudocode or a flowchart, a program that :
- Takes a number from the console
- Prints every Triangle number from 1 to that number
- If the number happens to also be a Prime number, do not print the Triangle number and normal and instead print “ Prime Number: N !” where N is the Prime Triangle number.