Commit e1249c63795e60f01dd4493f752ced9f67ab33c6
1 parent
f0c55387cc
Exists in
master
add debug lab2
Showing 2 changed files with 40 additions and 0 deletions Inline Diff
lab2/factorial.c
View file @
e1249c6
| File was created | 1 | #include <stdio.h> | ||
| 2 | ||||
| 3 | int main() | |||
| 4 | { | |||
| 5 | int i, num, j; | |||
| 6 | printf ("Enter the number: "); | |||
| 7 | scanf ("%d", &num ); | |||
| 8 | ||||
| 9 | for (i=1; i<num; i++) | |||
| 10 | j=j*i; |
lab2/printArray.c
View file @
e1249c6
| File was created | 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... |