C Language: Print a prime number between 100 and 200

Source: Internet
Author: User

#include <stdio.h>

#include <math.h>

int Main ()

{

int i = 0;

int count = 0;

for (i = 101; I <= 199; i + = 2)

{

int j = 0;

for (j = 3; J <= sqrt (i); j + = 2)

{

if (I%j = = 0)

{

Break ;

}

}

if (J >sqrt (i))

{

count++;

printf ("%d", i);

}

}

printf ("count=%d\n", count);

return 0;

}

Output Result:

101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 count=21

Please press any key to continue ...


This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1716583

C Language: Print a prime number between 100 and 200

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.