Hello, I am a student and a beginner learning c.
I need help where I did wrong in the following code
Code:
#include <stdio.h>
int main(void){ int s,j,i,r;
printf("Enter an integer: "); scanf("%d",&i);
s=i-1; int n[s];
for(j=1,s=0;s<i-1;j++,s++) { n[s]=j+1; r=n[s]%2; printf("n[%d]remainder2=%d \n",n[s]%2,r); }}
I am getting the output:
Code:
Enter an integer: 9
n[0]remainder2=0
n[1]remainder2=1
n[0]remainder2=0
n[1]remainder2=1
n[0]remainder2=0
n[1]remainder2=1
n[0]remainder2=0
n[1]remainder2=1
In the loop after executing two times, the same process repeats.
Thanks for the help