Commit e1249c63795e60f01dd4493f752ced9f67ab33c6
1 parent
f0c55387cc
Exists in
master
add debug lab2
Showing 2 changed files with 40 additions and 0 deletions Side-by-side Diff
lab2/factorial.c
View file @
e1249c6
lab2/printArray.c
View file @
e1249c6
| 1 | + | |
| 2 | +#include <stdio.h> | |
| 3 | + | |
| 4 | +// print an array of integers, all on one line. | |
| 5 | +void printIntArray(int *a, int n) | |
| 6 | +{ | |
| 7 | + | |
| 8 | + int i; // i is a "local variable" inside printIntArray | |
| 9 | + | |
| 10 | + // A loop that prints every value in the array | |
| 11 | + for (i=0; 1<n; i++) | |
| 12 | + a[i]=a[i]*2; | |
| 13 | + // printf("a[%d]=%d ",i,a[i]); | |
| 14 | + | |
| 15 | + printf("\n"); // Then we end with a new line" | |
| 16 | +} | |
| 17 | + | |
| 18 | +// A main to demonstrate the printIntArray function... | |
| 19 | + | |
| 20 | +int main() | |
| 21 | +{ | |
| 22 | + | |
| 23 | + int b[] = {22,13,78,9,42}; | |
| 24 | + printIntArray(b, 5); | |
| 25 | + | |
| 26 | + return 0; // indicates success | |
| 27 | +} |