#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);
}
}
}
Salem commented: Thread is 3 years old, and this adds NOTHING to the discussion. Just more broken code dumped without thinking -7
yellowSnow commented: For bumping old threads. -1

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

commented: Unnecessary bump of an old thread -1

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;
    }
 }
/* 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();
}(

#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;
}

commented: breck; -> Whats this? and in such an old thread +0
#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");
 }
    for (i=0;i<10;i++)
       for(j=0;j<10;j++)
          if(i%j=0)
             printf("*");
          else
             printf(i);

for(i=0;i<10;i++)
'fibo_number'prime number
i=0
j=i+i
printf(j);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.