nachiyappan


{ City } chennai
< Country > india
* Profession * fresher
User No # 58406
Total Questions Posted # 2
Total Answers Posted # 2

Total Answers Posted for My Questions # 2
Total Views for My Questions # 5691

Users Marked my Answers as Correct # 59
Users Marked my Answers as Wrong # 19
Questions / { nachiyappan }
Questions Answers Category Views Company eMail

Can any1 say how this prog logic works... i am weak in thread concept...pls explain step by step

1 Engineering AllOther 2727

pls explain this prog logic

1 Engineering AllOther 2964




Answers / { nachiyappan }

Question { Oracle, 74430 }

write a Program to dispaly upto 100 prime numbers(without
using Arrays,Pointer)


Answer

#include
#include
void main()
{
int i,j,c,n=1;
clrscr();
for(i=1;i<=100;i++)
{
n=n+1;
c=0;
for(j=1;j<=n;j++)
{
if(n%j==0)
c=c+1;
}
if(c==2)
printf("no. %d is prime",n);
else
printf("no. %d is not prime",n);
}
getch();
}

Is This Answer Correct ?    33 Yes 11 No

Question { Oracle, 74430 }

write a Program to dispaly upto 100 prime numbers(without
using Arrays,Pointer)


Answer

#include
#include
void main()
{
int i,j,c,n=1;
clrscr();
printf(" no. 1 is neither a prime nor composite no.");
for(i=1;i<100;i++)
{
n=n+1;
c=0;
for(j=1;j<=n;j++)
{
if(n%j==0)
c=c+1;
}
if(c==2)
printf("\n no. %d is prime",n);
else
printf("\n no. %d is not prime",n);
}
getch();
}

Is This Answer Correct ?    26 Yes 8 No