CSP2151 Workshop 3 Assignment

Edith Cowan University
School of Science        

CSP2151 Workshop 3

Design the following:

  1. Write a function int_max_3 that takes three int arguments and returns the largest of them as the value of the function.
  2. The function islower() returns true if its int argument is a lowercase character. Write your own version of islower() called myislower().
  3. 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!):
  4. Write a function int logstar(double) that calculates this function.

{`log x * {1 + log * (log2x) if x ≤ 1 otherwise`}

Design and Implement the following:

  1. 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.
  2. 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.


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:

CSP2151 Workshop 3 image 1

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.