#include<stdio.h>
int main()
{
FILE *f1;
f1=fopen(“PRINT_FILE.txt”,”w”);
if(f1==NULL){
printf(“Error file\n”);
return -1;
}
int n, i=3, count, c;
printf("Enter the number of prime numbers required\n");
scanf("%d",&n);
if ( n >= 1 )
{
printf("First %d prime numbers are :\n",n);
fprintf(f1,"2\n");
}
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
fprintf(f1,"%d\n",i);
count++;
}
i++;
}
return 0;
}