cpp1_code_x08

cpp1_code_x08 - CGS-2421 C+ EXAM 1 CODING PART SUMMER 2008...

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

CGS-2421 C++ EXAM 1 CODING PART SUMMER 2008 Name ______________________________________ Username _____________________ (10 points) 1. Write a function that implements the modulus operator %. The prototype for this function is given below: int modulus (int n, int div); where n is the number, div is the divisor and the function returns the remainder. In other words, modulus(a,b) will be equivalent to a%b. Obviously, you can not use % in your implementation. --------------------------------------------------------- Your Solution ------------------------------------------------------- int modulus(int n, int div) { return n-(n/div)*div; }

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

View Full Document
Name ______________________________________ Username _____________________EX1 (20 points) 2. Write a function called fractoint that converts double numbers (between 0 and 1) to integers. Prototype: int fractoint(double d); where d is a double between 1 and 0. fractoint(0.125)
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_x08 - CGS-2421 C+ EXAM 1 CODING PART SUMMER 2008...

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

View Full Document
Ask a homework question - tutors are online