开发者

how to remove the error shown?

"ILLEGAL USE OF FLOATING POINT"

#include<iostream.h>
#include<conio.h>
#include<process.h>
main()
{
    double a;
    cout<<"Enter a number\n";
    cin>>a;
    for(int j=2;j<=a;j++)
        if(a%j == 0)
        {
            cout<<"Its not a prime number\n";
            exit(0);
        }
 开发者_高级运维       else
            cout<<"Its a prime number\n";
            getch();
            return 0;
        }


Replace double a with an integer data type like int or long. You cannot do a modulus operation (%) on floating point numbers (hence the error about illegal use on floating point numbers).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜