source: soft/tp18/correction/main1.c @ 31

Last change on this file since 31 was 25, checked in by porquet, 14 years ago

corrections sur tp18

File size: 479 bytes
Line 
1#include "stdio.h"
2
3///////
4int main1()
5{
6        int opx;
7        int res;
8        int i;
9
10        tty_puts(" TASK 1 : FACTORIELLE \n");
11
12        while (1) {
13                tty_puts("\n*********************\n");
14                tty_puts("operand  = ");
15                tty_getw_irq(&opx);
16                tty_puts("\n");
17                if( (opx > 12) || (opx < 1) ) {
18                        tty_puts("operand must be larger than 0 and smaller than 13\n");
19                } else {
20                        res = 1;
21                        for(i=opx ; i>1 ; i--) res = res*i;
22                        tty_printf("factorielle(%d) = %d\n", opx, res);
23                }
24        }
25        return 0;
26} // end main
Note: See TracBrowser for help on using the repository browser.