write the program for prime numbers?

Answer Posted / nandhini

#include<stdio.h>
int main()
{
int i,j,n,count=0;
printf("Enter the number:");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0 && i/1==i)
{
count=count+1;
}
}
if(count==1)
{
printf("\n%d",i);
}
count=0;
}
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I access an I o board directly?

623


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

2650


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2118


What functions are used in dynamic memory allocation in c?

595


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

1633






difference between Low, Middle, High Level languages in c ?

1634


Using which language Test cases are added in .ptu file of RTRT unit testing???

3593


write a program to create a sparse matrix using dynamic memory allocation.

4373


What is the difference between union and structure in c?

575


Explain what are global variables and explain how do you declare them?

639


How can I do peek and poke in c?

617


Explain how do you determine a file’s attributes?

592


Explain the advantages of using macro in c language?

580


What is a class c rental property?

607


What does %2f mean in c?

674