100 to 200 to find the prime number of the C program, I don t know what went wrong, no result.

Updated on technology 2024-05-05
7 answers
  1. Anonymous users2024-02-09

    There are problems with your judgment, so I won't talk about the semicolon, I rewrote it, and your logic is not right, if(i%k!=0) cout<

    #include

    using namespace std;

    int main()

    int i,k;

    int flag;

    for(i=100;i<=200;i++)flag=-1;

    for(k=2;k<=(int)sqrt(i);k++)if(i%k==0)

    flag=0;

    break;

    if (flag!=0)

    cout

  2. Anonymous users2024-02-08

    #include

    #include

    using namespace std;

    int main()

    int i,k;

    for(i=100;i<=200;i++) You have one more garry for this part; It's an empty loop.

    for(k=2;k<=(int)sqrt(i);k++) here you also add one; is an empty loop.

    if(i%k!=0) cout

  3. Anonymous users2024-02-07

    for(i=100;i<=200;i++) is wrong here and should be removed.

    for(k=2;k<=(int)sqrt(i);k++) is wrong here and should be removed.

    The above are 2 empty for loops, and there is definitely no result.

  4. Anonymous users2024-02-06

    The for statement is not followed by a semicolon.

  5. Anonymous users2024-02-05

    Determining whether a number is x or not is prime is whether there is an epwinkbetween 2 - sqrt(x); No, it's prime.

    Then make a cycle from 100 - 200 to determine whether each number is prime.

  6. Anonymous users2024-02-04

    Several methods such as training loops and amorphous loops, arrays and pointers are all possible.

  7. Anonymous users2024-02-03

    Two methods: 1. Violence; 2. Finding prime numbers by screening method.

    The first type: the brute force method, use each number from 100 to 200 in the cycle to judge it, and output it if it is a prime number.

    #include

    #include

    using namespace std;

    bool prime(int num)

    int main()

Related questions
5 answers2024-05-05

There should be a condition:

main() >>>More

8 answers2024-05-05

Spring The lovely spring girl, with light steps, came to the world, and the scene of vitality came in all directions, and the whole world seemed to have just woken up from a long sleep. >>>More

3 answers2024-05-05

I like to quietly gaze at the teacher's bright eyes—such beautiful and innocent eyes, which warm people's hearts. When I stepped into the campus, it was your eyes that gave me kindness; When I was disappointed in the exam room, it was your eyes that gave me encouragement; When I am complacent, it is your eyes that warn me. Flashing with light but without a hint of flashiness, full of truth but without a trace of falsehood, slightly serious but not a trace of sharpness. >>>More

4 answers2024-05-05

No, you write it yourself, and you copy it.

12 answers2024-05-05

At 8 p.m. on August 8, 2008, the 29th Beijing Olympic Games opened on time! >>>More