开发者

how to remove the error shown?

开发者 https://www.devze.com 2023-03-01 23:59 出处:网络
\"ILLEGAL USE OF FLOATING POINT\" #include<iostream.h> #include<conio.h> #include<process.h>

"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

精彩评论

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