## Please Help! a.s.a.p!!!!!!!!!!!!!!!!!!!!!!!!!!

## Please Help! a.s.a.p!!!!!!!!!!!!!!!!!!!!!!!!!!

**Guest**(visitor)

(OP)

email: k0008990@kingston.ac.uk

Exercise 1

The following is a function declaration for finding the area of a rectangle.

int rectangle_area(int width, int height);

Implement a function for finding the area of a rectangle.

Use the following code to test your program

// author

// date

// title

#include <iostream.h>

int rectangle_area(int width, int height);

void main()

{

int w, h;// width and height of rectangle

int a;// area

cout << "What is the width of the rectangle? " << endl;

cin >> w;

cout << "What is the height of the rectangle?" << endl;

cin >> h;

a = rectangle_area(w, h);

cout << "The area of the rectangle is " << a << endl;

}

// rest of the code goes here

Exercise 2

You have previously written a program for displaying times-tables, e.g.

1 x 2 = 2

2 x 2 = 4

2 x 3 = 6...

Write a function called void table(int x) which prints out the x times tables.

The following code should be used for testing the program...

// Times Tables Tester

// date

// author

#include <iostream.h>

void table(int x);

void main()

{

for (int i=1;i<=12;i++)

table(i);// display i times table

}

// rest of your code...

Exercise 3

Write a function:

float CtoF(float C)

which converts degrees Centigrade to Fahrenheight

and a second function:

float FtoC(float F)

which converts degrees Fahrenheit to Centigrade.

The formula is C = (F-32)*5/9

The main program runs in a loop, asking the user which conversion they want to do (or 0 to exit), and then a value for the temperature. The program should display the converted temperature.

If the following temperatures are entered, the program should print out an informational message:

TemperatureMessage

<273CInvalid temperature - below absolute zero!

0CFreezing point of water

100CBoiling point of water

>5000CHotter than temperature of the Sun

Hint: the temperatures are shown in degrees Centigrade.

Exercise 4

A large number of functions to do maths are available, when you add the line

#include <math.h>

to the top of your program.

These include:

double sin(double alpha)

double cos(double alpha)

double tan(double alpha)

double sqrt(double x)

For the trig functions, angle alpha is in radians.

To convert from radians to degrees, use:

angle_in_deg = angle_in_rad*180/PI;

where const double PI = 3.14159;

Problem:

The figure below shows a person looking at a high wall.

Write a function:

double height_of_wall(double p, double alpha, double d)

which returns the height of the wall.

Exercise 5

A. Write a function:

int odd(int x)

which returns 1 if x is odd, and 0 otherwise

B. Write a function:

int isPositive(int x)

which returns 1 if x is positive, and 0 otherwise

TRICKY...

C. Write a function

int isPrime(int x)

which returns 1 if x is a prime number, and 0 otherwise

Exercise 1

The following is a function declaration for finding the area of a rectangle.

int rectangle_area(int width, int height);

Implement a function for finding the area of a rectangle.

Use the following code to test your program

// author

// date

// title

#include <iostream.h>

int rectangle_area(int width, int height);

void main()

{

int w, h;// width and height of rectangle

int a;// area

cout << "What is the width of the rectangle? " << endl;

cin >> w;

cout << "What is the height of the rectangle?" << endl;

cin >> h;

a = rectangle_area(w, h);

cout << "The area of the rectangle is " << a << endl;

}

// rest of the code goes here

Exercise 2

You have previously written a program for displaying times-tables, e.g.

1 x 2 = 2

2 x 2 = 4

2 x 3 = 6...

Write a function called void table(int x) which prints out the x times tables.

The following code should be used for testing the program...

// Times Tables Tester

// date

// author

#include <iostream.h>

void table(int x);

void main()

{

for (int i=1;i<=12;i++)

table(i);// display i times table

}

// rest of your code...

Exercise 3

Write a function:

float CtoF(float C)

which converts degrees Centigrade to Fahrenheight

and a second function:

float FtoC(float F)

which converts degrees Fahrenheit to Centigrade.

The formula is C = (F-32)*5/9

The main program runs in a loop, asking the user which conversion they want to do (or 0 to exit), and then a value for the temperature. The program should display the converted temperature.

If the following temperatures are entered, the program should print out an informational message:

TemperatureMessage

<273CInvalid temperature - below absolute zero!

0CFreezing point of water

100CBoiling point of water

>5000CHotter than temperature of the Sun

Hint: the temperatures are shown in degrees Centigrade.

Exercise 4

A large number of functions to do maths are available, when you add the line

#include <math.h>

to the top of your program.

These include:

double sin(double alpha)

double cos(double alpha)

double tan(double alpha)

double sqrt(double x)

For the trig functions, angle alpha is in radians.

To convert from radians to degrees, use:

angle_in_deg = angle_in_rad*180/PI;

where const double PI = 3.14159;

Problem:

The figure below shows a person looking at a high wall.

Write a function:

double height_of_wall(double p, double alpha, double d)

which returns the height of the wall.

Exercise 5

A. Write a function:

int odd(int x)

which returns 1 if x is odd, and 0 otherwise

B. Write a function:

int isPositive(int x)

which returns 1 if x is positive, and 0 otherwise

TRICKY...

C. Write a function

int isPrime(int x)

which returns 1 if x is a prime number, and 0 otherwise

## RE: Please Help! a.s.a.p!!!!!!!!!!!!!!!!!!!!!!!!!!

i think you should do your homework by yourself. these are exercises from the very beginning of c and you can find the solutions in nearly every beginner - c - tutorial.

download some an you will drag and drop and never learn how to program i c.

noka

## RE: Please Help! a.s.a.p!!!!!!!!!!!!!!!!!!!!!!!!!!

Russ

bobbitts@hotmail.com

http://home.earthlink.net/~bobbitts

## RE: Please Help! a.s.a.p!!!!!!!!!!!!!!!!!!!!!!!!!!

wont be able to compile his test programs with a C compiler though.

## RE: Please Help! a.s.a.p!!!!!!!!!!!!!!!!!!!!!!!!!!

Guest(visitor)