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
How a string is stored in c?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
What are void pointers in c?
Write a program on swapping (100, 50)
How can this be legal c?
What is data type long in c?
What is the difference between volatile and const volatile?
When the macros gets expanded?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
Write the syntax and purpose of a switch statement in C.
What are runtime error?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
What is the difference between malloc calloc and realloc in c?
What is structure in c explain with example?
why return type of main is not necessary in linux