ass5sol

# ass5sol - Introduction to Computer Engineering 1 Assignment...

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

Assignment 5 Datapaths Due Date: 5:00 PM Wednesday 31 th March 2010 Question 1 /*----------------------------------------------------------------------*/ /* Program Name: factorial */ /* Function: Computes the factorial of a command line */ /* argument. */ /* Usage: % factorial [long] */ /* Author: Julien Cassis */ /* Date: March 22, 2010 */ /*----------------------------------------------------------------------*/ #include <stdio.h> void factorial (long argument, long *result); int main (int argc, char *argv[]){ long argument, result; if (argc != 2) { printf("Usage: factorial [long]\n"); return(0); } sscanf(argv[1],"%ld",&argument); factorial(argument,&result); printf("%ld! = %ld\n",argument,result); return(0); } /*----------------------------------------------------------------------*/ /* Recursive factorial function */ /* void factorial (long argument, long *result) */ /*----------------------------------------------------------------------*/ void factorial (long argument, long *result){

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/06/2010 for the course ENG ECSE221 taught by Professor Ferri during the Winter '09 term at McGill.

### Page1 / 7

ass5sol - Introduction to Computer Engineering 1 Assignment...

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

View Full Document
Ask a homework question - tutors are online