I'm working on homework for C programming class, and I can't figure this out. Question: "Write a program that obtains a number n from the user and prints the first n prime numbers, with one number printed per line"

So far we have learned for, if, while statements...

I have a for loop to calculate the nth prime numbers. But I'm not sure if "i<=n" should be the condition. Because if "i<=n", then when you want n=5 prime numbers, you won't get 5 numbers. underneath it is an if statement to determine if the number is prime or not. Then I was trying to figure out to display them, if using an IF statement would work.

please help, thanks

Code:#include<stdio.h> int main() { int n,i,f=0; printf("Enter value for n: "); scanf("%i",&n); for(i=2;i<=n;i++) { if(n%i==0) f=1; if(f !=1) printf("%d",i); } return(0); }