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
Do you know the purpose of 'register' keyword?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
What are predefined functions in c?
What is || operator and how does it function in a program?
What is a ternary operator in c?
Explain modulus operator.
What is #ifdef ? What is its application?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
How can I do serial ("comm") port I/O?
Is it possible to initialize a variable at the time it was declared?
Is using exit() the same as using return?
What are the different types of control structures?
Tell us two differences between new () and malloc ()?
Why we write conio h in c?
What header files do I need in order to define the standard library functions I use?