>>543
適当に行詰めたから展開してなー

#include<stdio.h>
#include<math.h>
int chkprime(int n){
    int x;
    if(n < 2)return 0;
    for(x = (int)sqrt((double)n);x!=1 && n%x;)--x;
    return x==1;
}
int main(void){
    int low,high,count;FILE*fp;
    puts("上限と下限を入力してください");scanf("%d%d",&low,&high);
    if(low > high){int c = low ; low = high; high = c;}
    if(low  < 0){fputs("警告: 範囲に負が含まれてる\n",    stderr);return 8;}
    if(high < 2){fputs("警告: 範囲内に素数が存在しない\n",stderr);return 8;}
    if((fp=fopen("result.txt","w"))==NULL){fputs("エラー: ファイルの作成に失敗\n",stderr);return 8;}
    for(count=0;low <= high;++low)if(chkprime(low))fprintf(fp,"%12d%c",low,++count % 5 ? ' ':'\n');
    if(count % 5)fprintf(fp,"\n");
    return 0;
}