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

Answer Posted / nachiyappan

#include<stdio.h>
#include<conio.h>
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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the process to generate random numbers in c programming language?

618


What are dangling pointers? How are dangling pointers different from memory leaks?

633


Which is best linux os?

574


Is file a keyword in c?

512


Why c is called object oriented language?

592






in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

7417


What is string constants?

666


What are disadvantages of C language.

653


What are the advantages of using new operator as compared to the function malloc ()?

762


please explain every phase in the "SDLC" in the dotnet.

2182


What is sizeof int in c?

613


What is the function of multilevel pointer in c?

679


What does 1f stand for?

618


Explain can static variables be declared in a header file?

688


How old is c programming language?

591