Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

i want a code to find prime numbers in a given range using while loop.

$
0
0
#include<stdio.h>
#include<conio.h>
void main()
{ int x,z,y=2;
//x is lower limit and z is upper limit of range 
printf("enter the no.");
scanf("%d%d",&x&z);
while(x<=z)
{
    while(y<=x)
    {
        if(x%y==0)
        {
        break;
        }
        y++;
        if(x==y)
        printf("prime no.=%d \n",x);

    }
    x++;
}
getch();
}

what would be the output??


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>