write the program for prime numbers?

Answer Posted / d.sukumar

void main()
{
int i,k;int count=0;
int n;
printf("enter a no");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
k=n%i;
if(k==0)
{
count++;
}
}
if(count==1)
printf("prime");
else
printf("not prime");
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

swap 2 numbers without using third variable?

658


What is difference between function overloading and operator overloading?

657


How can I implement sets or arrays of bits?

603


Is main a keyword in c?

630


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

1739






Disadvantages of C language.

655


Can i use “int” data type to store the value 32768? Why?

756


Explain how can I pad a string to a known length?

652


What is a string?

664


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1981


Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

1423


What is derived datatype in c?

631


Explain the difference between call by value and call by reference in c language?

645


Why is c known as a mother language?

741


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

683