I am trying to ask for the user input and I am unable to get it to work. I know there is a way to do this without functions, but I want to have my main function separate from the algorithm. I want the output to display the correct level inputted.
#include <stdio.h>
int main () {
int levels, i, j, result;
printf("Please enter how many levels of Pascal's Triangle you would like to see:");
scanf("%d",&levels);
newfunc();
}
int newfunc() {
int levels, i, j, result;
int num[28];
for(i=0; i < levels; i++) {
num[i] = 1;
for (j = i - 1; j > 0; j--) {
num[j] += num[j - 1];
}
result = (levels - i);
for (j = 0; j <= i; j++) {
printf("%d ", num[j]);
}
printf("\n");
}
}