×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

(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
}
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:
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

hello timtiny,

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

well the functions that he needs should be the same in c/c++.

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

(OP)
I wanted to do c course how will i start my studies, would we get any online materials to study and write the exams and get certification from the brain bench.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!