Question 20: How many prime numbers are there between-and all prime numbers are output.

Source: Internet
Author: User

/*************************************** ************************
* *** Auther: liuyongahui
* ***** Date:
* ** Language: C
**************************************** ***********************/
/*
Question 20: How many prime numbers are there between-and all prime numbers are output.
*/

# Include <stdio. h>

Int main ()
{
Int I;
Int j;
Int flag; // flag
Int num = 0; // count
Int a [100]; // stores prime numbers.

For (I = 101; I <200; I ++)
{
Flag = 1;
For (j = 2; j <= I/2; j ++) // The number of I division and 2-i/2 to verify whether it is a prime number.
{
If (I % j = 0) // if it can be integer, it is not a prime number.
{
Flag = 0;
}
}
If (flag)
{
A [num ++] = I;
}
}
Printf ("there are % d prime numbers, which are \ n", num );

For (I = 0; I <num; I ++)
{
Printf ("% d \ n", a [I]);
}
}

 

 

Related Article

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.