write the program for prime numbers?
Answer Posted / karthik
#include<stdio.h>
#include<conio.h>
void main()
{
int n,flag;
clrscr();
printf("\n Enter prime no\n");
scanf("%d",&n);
for(int i=2;i<=n/2;i++)
{
if(n%i==0)
{
flag=0;
break;
}
}
if(flag==0)
printf("\n%d is not prime",n);
else
printf("\n %d is prime",n);
getch();
}
Is This Answer Correct ? | 21 Yes | 17 No |
Post New Answer View All Answers
What is the purpose of realloc()?
Why can’t we compare structures?
What does #pragma once mean?
What is table lookup in c?
What is a pointer variable in c language?
how can f be used for both float and double arguments in printf? Are not they different types?
What are pointers? What are different types of pointers?
What is difference between static and global variable in c?
Can you please compare array with pointer?
Can we change the value of constant variable in c?
What is #include in c?
Explain setjmp()?
What is && in c programming?
What are Macros? What are its advantages and disadvantages?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?