write the program for prime numbers?

Answer Posted / felix c. intelegando

#include<stdio.h>
#include<conio.h>


int main(void)
{
int i,n,count=0;
printf("Enter Number: ");
scanf("%d",&n);
for(i=2;i<n;i++)

{
if(n%i==0)
{
count++;
}
}
if(count>1)
{
printf("Not Prime ");

}
else
printf("Prime");

getch();
return 0;
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the size of enum in bytes?

586


Are there namespaces in c?

566


a program that can input number of records and can view it again the record

1482


`write a program to display the recomended action depends on a color of trafic light using nested if statments

1631


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3655






What is the difference between c and python?

584


What is enumerated data type in c?

623


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

1890


What is a const pointer in c?

670


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

656


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

668


What is the purpose of & in scanf?

594


What does %p mean c?

627


What is difference between function overloading and operator overloading?

655


string reverse using recursion

1809