how can i get rid of this error?
you are requesting user input with scanf, what number do you input?
I ask because this works:
#include<stdio.h>
int main()
{
int n1=0, n2=1, n3, num;
printf("Enter number of elements of the fibonacci series");
//scanf("%d", &num); // removed scanf
num = 4; // fixed number to test the code
for(int i=3; i<=num; i++)
{
n3=n1+n2;
printf("\n%d ", n3); // added new line
n1=n2;
n2=n3;
}
return 0;
}
and prints:
Enter number of elements of the fibonacci series
1
2