Question

rite a program to print prime numbers between 50 to 500, using while statement.) Q3- W (8 Marks) 04-if I Write C++ piece of c

What is the solution ??

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q3)

//language: C++

//////////////////////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;

int main()
{
    int low=50, high=500, i, flag;

    

    cout << "Prime numbers between " << low << " and " << high << " are: ";

    while (low < high)
    {
        flag = 0;
        i = 2;

        while( i <= low/2)
        {
            if(low % i == 0)
            {
                flag = 1;
                break;
            }
        i=++i;
        }

        if (flag == 0)
            cout << low << " ";

        ++low;
    }

    return 0;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Add a comment
Know the answer?
Add Answer to:
What is the solution ?? rite a program to print prime numbers between 50 to 500, using while statement.) Q3- W (8 Marks) 04-if I Write C++ piece of code that make Х, X6 Х, Х, X3 X2 X, Xo S Marks)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT