Generate prime numbers from 100 to 200 - C

Q. Write a program to generate prime numbers from 100 to 200
BIT_FirstSem_2016_12No_8Marks_Solution
==> Code goes like this: 

#include<stdio.h>
int main()
{
   int i,j,count;
printf("Prime numbers from 100 to 200 are:\n");
for(i=100;i<=200;i++)
{
    count=0;
    for(j=2;j<=i/2;j++)
        {
        if(i%j==0)
            {
            count++;
            break;
            }
        }
    if(count==0 && i!=1)
        {
        printf("%d ",i);
        }
}
return 0;
}

Output :





If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you






Share on Google Plus

About Nepali Xoro

Interested in Information Technology, Spreading Knowledge for Nepalease IT Students."Loves Traveling", Listen Music and Surfing web.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment