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
How will you delete a node in DLL?
How can I open files mentioned on the command line, and parse option flags?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
What is structure and union in c?
What is the collection of communication lines and routers called?
Are c and c++ the same?
Explain the use of 'auto' keyword in c programming?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
What is declaration and definition in c?
What is modeling?
What is pre-emptive data structure and explain it with example?
What is the purpose of main( ) in c language?
What is a header file?
What is a pragma?