write the program for prime numbers?

Answer Posted / sreejesh1987

//Output primes upto limit n(Give n>2)
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("\t\t\tPRIME NUMBERS\n");
printf("Enter n:");
scanf("%d",&n);
printf("\n\t2");
for(i=3;i<=n;i++)
for(j=2;j<i,i%j!=0;j++)
if(i-1==j)
printf("\n\t%d",i);
getch();
}

Is This Answer Correct ?    11 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which header file is essential for using strcmp function?

937


What is adt in c programming?

609


int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer

654


explain what is fifo?

632


What is array in c with example?

615






What is the right way to use errno?

620


Explain zero based addressing.

608


Explain how can you tell whether a program was compiled using c versus c++?

578


What are variables c?

615


Is there a way to jump out of a function or functions?

634


How can I determine whether a machines byte order is big-endian or little-endian?

617


List the difference between a "copy constructor" and a "assignment operator"?

583


What is an expression?

654


Difference between macros and inline functions? Can a function be forced as inline?

709


What is a lvalue

664