Write a program to find whether the given number is prime or
not?
Answer Posted / sudha
#include<stdio.h>
#include<conio.h>
void main()
{
int isprime=1;
int n,i;
printf("enter a number");
scanf("%d",&n);
if(i=2;i<=n/2;i++)
{
if((n%i)==0)
{
isprime=0;
break;
}
}
if(isprime==1)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}
Is This Answer Correct ? | 18 Yes | 5 No |
Post New Answer View All Answers
What is #define in c?
What are the header files used in c language?
How can you allocate arrays or structures bigger than 64K?
Why header files are used?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What is c token?
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
Why does everyone say not to use scanf? What should I use instead?
What is the difference between null pointer and wild pointer?
What is property type c?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
What is the correct declaration of main?
What are the different file extensions involved when programming in C?
What is preprocessor with example?