Question #60577

Write a program in c++ to print the prime numbers between 100-200
1

Expert's answer

2016-06-30T04:09:05-0400

Answer on Question #60577 - Programming & Computer Science - C++

Question:

Write a program in c++ to print the prime numbers between 100-200.

Solution:

#include <iostream>
#include <math.h>
int main()
{
    for (int i=100; i<200; i++)
    {
        for (int j=2; j*j<=i; j++)
        {
            if (i % j == 0)
            {
                break;
            }
            else if (j+1 > sqrt(i))
            {
                std::cout << i << " ";
            }
        }
    }
    return 0;
}

Answer:

101 103 107 109 113 127 131 137 139 149 151 157 163 167 173

179 181 191 193 197 199</math.h></iostream>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS