/*-*-mode:c-*- *************************************************************************** CSN381: Project 1 (1:a, b,c,) http://homepage.mac.com/hteric/Project1.pdf *************************************************************************** File : isodd.c Author : Jeremy Russell Date : September 5, 2002 Description : 1. Write a function called isodd which satisfy the following 3 conditions: a. Takes a positive integer as an argument b. Returns 1 if the argument is odd\ (like 1,3,5,7,9,...) c. Returns 0 if the argument is even (like 2,4,6,8,...) Also use it in the main to print out all odd integers between (and include) 1 and 200 This program should be named as "isodd.c", submit isodd.c in source code and hard copy form. ***************************************************************************/ /* Inlcude section. */ #include <stdio.h> int isodd ( int ); /*************************************************************************** Function : main Author : Jeremy Russell Date : September 5, 2002 Description : Main function of the isodd program. Prints out all odd numbers between 1 and 200, inclusive. Arguments : void Returns : void Notes : None See Also : None ***************************************************************************/ int main ( void ) { /* Vatiable declaration. */ int iterate; /* Main body. */ for ( iterate = 1; iterate <= 200; iterate++) { if ( isodd( iterate ) ) printf ("%d\n", iterate); } return 0; } /*************************************************************************** Function : isodd Author : Jeremy Russell Date : September 5, 2002 Description : Evaluate an integer to seeif it is odd. Arguments : * int number Returns : true or false (0 || 1) Notes : None See Also : None ***************************************************************************/ int isodd ( int number ) { return number % 2; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 2117 | Jeremy Russell |
Project 1 nsplit.c has problesm still. |
||
#1 | 2116 | Jeremy Russell | Project 1, 1 |