write the program for prime numbers?

Answer Posted / umesh prajapati

/* find the number is prime or not prime. umesh prajapati*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,c,r;
clrscr();
printf("ENTER THE VALUE");
scanf("%d",&n);
if(n==2)
printf("THE NUMBER IS CO-PRIME");
else
{
c=2;
while(c<n)
{
r=n%c;
if(r==0)
{
printf("GIVEN NUMBER IS NOT PRIME");
break;
}
c++;
}
if(r>0)
printf("GIVEN NUMBER IS PRIME");

}
getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the sizeof () a pointer?

550


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3298


How can I automatically locate a programs configuration files in the same directory as the executable?

633


Explain heap and queue.

590


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1663






find out largest elemant of diagonalmatrix

1651


Can stdout be forced to print somewhere other than the screen?

627


What is the difference between the = symbol and == symbol?

630


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

755


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

1728


When is a void pointer used?

679


Write a program of prime number using recursion.

622


What are structure types in C?

672


What is the difference between c &c++?

648


What is malloc calloc and realloc in c?

671