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 / shweta

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

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I remove the leading spaces from a string?

1092


How we can insert comments in a c program?

1066


When should I declare a function?

1052


How do you do dynamic memory allocation in C applications?

1039


Linked lists -- can you tell me how to check whether a linked list is circular?

1030


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

2134


what do you mean by inline function in C?

1003


Does c have circular shift operators?

1179


List the difference between a "copy constructor" and a "assignment operator"?

955


What are the advantage of c language?

998


Explain what are the advantages and disadvantages of a heap?

1027


What is the use of void pointer and null pointer in c language?

1067


What does #pragma once mean?

1106


Are comments included during the compilation stage and placed in the EXE file as well?

1026


What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

1191