write the program for prime numbers?

Answer Posted / ashok

void main()
{
int i,n;
clrscr();
printf("\nEnter the range:");
scanf("%d",&n)
printf("Prime numbers are:");
for(i=1;i<=n;i++)
{
if(i==2 || i==3 || i==5 || i==7)
printf("%d ",i);
if(i%2!=0 && i%3!=0 && i%5!=0 && i%7!=0)
printf("%d ",i);
}
getch();
}

Is This Answer Correct ?    7 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is %lu in c?

683


Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

1620


What's a good way to check for "close enough" floating-point equality?

627


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

3730


Tell me about low level programming languages.

642






What is the difference between a string and an array?

706


Give basis knowledge of web designing ...

1574


Explain the difference between null pointer and void pointer.

667


What is the right way to use errno?

620


How can I get back to the interactive keyboard if stdin is redirected?

668


You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;ia1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }

2712


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

671


what is the diffrenet bettwen HTTP and internet protocol

1387


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

660


What is the scope of static variable in c?

533