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 graph in c?
Who is the main contributor in designing the c language after dennis ritchie?
What is the meaning of typedef struct in c?
Write a program to know whether the input number is an armstrong number.
Write a program to print numbers from 1 to 100 without using loop in c?
how to construct a simulator keeping the logical boolean gates in c
What is a memory leak? How to avoid it?
How can I write a function that takes a format string and a variable number of arguments?
Is null a keyword in c?
What is the difference between declaring a variable and defining a variable?
What is #error and use of it?
int i=10; printf("%d %d %d", i, i=20, i);
Can we declare variables anywhere in c?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
Is c compiled or interpreted?