Systemnahe Programmierung in C: for-Schleifen |
|
1long int
2fac (int val)
3{
4 int j;
5 long int fact = 1;
6
7 for (j = 2; j <= val; ++j)
8 {
9 fact = fact * (long int) j;
10 }
11
12 return fact;
13}
|
1#include <stdio.h>
2
3/* header file fuer isdigit() */
4
5#include <ctype.h>
6
7int
8makeInt (void)
9{
10 int num = 0, digit;
11
12 for (digit = getchar ();
13 isdigit (digit);
14 digit = getchar ())
15 {
16 num = num * 10;
17 num = num + (digit - '0');
18 }
19
20 return num;
21}
|
1#include <stdio.h>
2
3/* header file fuer isspace() */
4
5#include <ctype.h>
6
7void
8skipSpaces (void)
9{
10 int c;
11
12 for (c = getchar ();
13 isspace (c);
14 c = getchar ())
15 ;
16
17 ungetc (c, stdin);
18}
|
Letzte Änderung: 11.01.2007 | © Prof. Dr. Uwe Schmidt |