cpp1_code_s08 - CGS-2421 C+ EXAM 1 USERNAME _ CODING PART...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CGS-2421 C++ EXAM 1 CODING PART SPRING 2008 USERNAME ___________________ NAME __________________________________ 1. (15 pts)Write a function called step that implements the following equations: n+1 for n < x <= n+1, n >=0 and an integer f(x) = 0 for x=0 n for n <= x < n+1, n < 0 and an integer Prototype: double step(double x); Examples: double d = step(3.25); -> copies 4 to d cout << step(-2.82); -> prints -3 cout << step(0); -> prints 0 Hint: You may use functions ceil() and floor() in your solution. --------------------------------------------------------- Your Solution ------------------------------------------------------- double step( double x) { if (x>0) return ceil (x); else if (x==0) return 0; else return floor (x); }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
USERNAME ___________________ NAME __________________________________ 2.(15pts) Write a function called temp_conv that converts from celcius (C) to fahrenheit (F). F = (9/5) * C + 32 The function receives the temperature in celcius and determines the temperature in fahrenheit. Since the absolute zero is at -273 C, any input less
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 3

cpp1_code_s08 - CGS-2421 C+ EXAM 1 USERNAME _ CODING PART...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online