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

What are volatile variables in c?

526


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

672


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

1310


What are the application of c?

652


How do you initialize pointer variables?

617






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

1583


What do you know about the use of bit field?

614


What is the purpose of type declarations?

683


What is the purpose of & in scanf?

603


How many bytes is a struct in c?

730


why return type of main is not necessary in linux

1710


Hai what is the different types of versions and their differences

1495


What are structure types in C?

677


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2659


What is the difference between c and python?

588