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


Please Help Members By Posting Answers For Below Questions

What is #define in c?

833


What are the header files used in c language?

807


How can you allocate arrays or structures bigger than 64K?

914


Why header files are used?

856


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); }

1159


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.

1764


What is c token?

839


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

873


Why does everyone say not to use scanf? What should I use instead?

1087


What is the difference between null pointer and wild pointer?

934


What is property type c?

852


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

2126


What is the correct declaration of main?

918


What are the different file extensions involved when programming in C?

1021


What is preprocessor with example?

795