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
What is the process to generate random numbers in c programming language?
What are dangling pointers? How are dangling pointers different from memory leaks?
Which is best linux os?
Is file a keyword in c?
Why c is called object oriented language?
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
What is string constants?
What are disadvantages of C language.
What are the advantages of using new operator as compared to the function malloc ()?
please explain every phase in the "SDLC" in the dotnet.
What is sizeof int in c?
What is the function of multilevel pointer in c?
What does 1f stand for?
Explain can static variables be declared in a header file?
How old is c programming language?