write the program for prime numbers?

Answer Posted / gnanasekaran

int main()
{
int i,j,n,f=0;
printf("Enter the length\n");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
for(j=2;j<i;j++)
{
if((i%j)==0)
{
f=1;
break;
}
f=0;
}
if(f==0)
printf("%d ",i);
}
}

Is This Answer Correct ?    139 Yes 81 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is typeof in c?

611


typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none

720


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1458


Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

2524


What are derived data types in c?

618






will u please send me the placement papers to my mail???????????????????

1367


What is strcpy() function?

662


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1516


Is there any possibility to create customized header file with c programming language?

630


Can you tell me how to check whether a linked list is circular?

781


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

588


What is a c token and types of c tokens?

594


What is #include stdio h and #include conio h?

605


What are the different types of control structures?

590


What is C language ?

1533