Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to find the given number is prime or not?

Answer Posted / amit kumar

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,flag=0,ctr;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=sqrt(n);ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==0)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are static variables in c?

1088


What do you mean by a local block?

1091


Write a simple code fragment that will check if a number is positive or negative.

1164


write a program to find the given number is prime or not

4778


What is the difference between single charater constant and string constant?

1100


Explain what is wrong with this program statement? Void = 10;

1272


What do you know about the use of bit field?

1051


What are the primitive data types in c?

1087


What is an example of structure?

1045


How can I insert or delete a line (or record) in the middle of a file?

1022


Why do we use int main?

1107


What is logical error?

1136


Write a C program in Fibonacci series.

1098


How is a pointer variable declared?

1104


What will be your course of action for a push operation?

1115