Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
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 << &quot;What is the width of the rectangle? &quot; << endl;
cin >> w;
cout << &quot;What is the height of the rectangle?&quot; << endl;
cin >> h;
a = rectangle_area(w, h);
cout << &quot;The area of the rectangle is &quot; << 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
 
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.

 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top