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
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
How does selection sort work in c?
How can I call fortran?
how to capitalise first letter of each word in a given string?
How can I get the current date or time of day in a c program?
Write a program for finding factorial of a number.
Why doesnt that code work?
string reverse using recursion
write a program to rearrange the array such way that all even elements should come first and next come odd
What are header files in c programming?
What is the sizeof () operator?
provide an example of the Group by clause, when would you use this clause
What are the types of unary operators?
Which header file is used for clrscr?
What are the different types of errors?