用while语句求1~100的质数

#include <iostream>
#include <cmath>
using namespace std;
/* run this program using the console pauser or add your own getch, system(“pause”) or input loop */

int main(int argc, char** argv) {
    int i,j,k,flag;
    i=2;
    while(i<=100)
    {
    flag=1;
    k=sqrt(i);
    j=2;
    while(j<=k)
    {if(i%j==0)
    {flag=0;
    break;
    }
    j++;
    }
    if(flag)
    cout<<i<<“是质数.”<<endl;
    i++;
    }
    return 0;
}