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 1f in c?
write a program to create a sparse matrix using dynamic memory allocation.
Array is an lvalue or not?
How to write a code for reverse of string without using string functions?
What is getch () for?
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
Can you tell me how to check whether a linked list is circular?
Why isn't it being handled properly?
How can I prevent another program from modifying part of a file that I am modifying?
Is it better to use a macro or a function?
Where are some collections of useful code fragments and examples?
Explain how are portions of a program disabled in demo versions?
Can we initialize extern variable in c?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?