-3
#include<stdio.h>
void main()
    int i,j,prime;
for(i=2;i<=500;i++)
for(j=2;j<500;j++)
{
if(i%j=o)
{
 prime=0;
break;
}
prime=1;
if(prime)
{
printf("\n%d",i);
}
}
}
Votes + Comments
For bumping old threads.
Thread is 3 years old, and this adds NOTHING to the discussion. Just more broken code dumped without thinking
-2

hi,
i m karan
dear thx u very much
i need the coading for last few week

i dont no who r u ?
my wishes with u dear
i wish u will achieve all u goal

Votes + Comments
Unnecessary bump of an old thread
-2

To print prime numbers from 1 to 500 using for loop following program is use.

#include<stdio.h>
 void main()
 {
   int c=0;
   for(int i=0;i<=500;i++).
    {
      for(int j=2;j<i;j++)
      { 
       if(i%j==0)
         c=c+1;
      }
    if(c==0)
     {
       printf(i,"\n");
     }
    c=0;
    }
 }
-1
/* print prime number using for loop */

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
clrscr();
int i,j,n;
printf("Enter a value : ");
scanf("%d",&n);
printf("2 3 ");
for(i=2;i<=n;i++)
    {
    for(j=2;j<=sqrt(i);j++)
      {
      if(i%j==0)
        {
        break;
        }
        if(j>sqrt(i)-1)
        printf("%d ",i);
      }

    }
getch();
}(

Edited by mike_2000_17: Fixed formatting

-2

#include<iostd.h>
int main()
{
int i,num;
scanf("%d",&num);
for(i=2;i<num;i++)
{
if(num%i==0){
c=1;
}
breck;
}
if(c==1)printf("number is prime");
else
printf("not a prime number");
return 0;
}

Votes + Comments
breck; -> Whats this? and in such an old thread
-1
#include<stdio.h>
#include<conio.h>
void main()
{
 int flag=0;
 int a=11,i,temp,temp=a;
 for(i=1;i<=temp;i++)
 {
if((a%i)==0)
{flag++;
}
}
if(flag==2)
{
 printf("prime");
 }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.