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 1f in c?

1845


write a program to create a sparse matrix using dynamic memory allocation.

4377


Array is an lvalue or not?

644


How to write a code for reverse of string without using string functions?

1583


What is getch () for?

683






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

1466


Can you tell me how to check whether a linked list is circular?

781


Why isn't it being handled properly?

651


How can I prevent another program from modifying part of a file that I am modifying?

618


Is it better to use a macro or a function?

659


Where are some collections of useful code fragments and examples?

723


Explain how are portions of a program disabled in demo versions?

659


Can we initialize extern variable in c?

641


typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none

720


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

585