write the program for prime numbers?

Answer Posted / nitesh sanwal

#include<stdio.h>
#include<math.h>
void main()
{
int n,i,prime=1;
printf("input the numbers");
scanf("%d",&n);
for(i=2;i<=sqrt(n);i++)
if(n%i==0)
{
prime=0;
break;
}
if(prime)
printf("%d is a prime number",n);
else
printf("%d is a not a prime number",n);
}

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the benefit of using enum to declare a constant?

853


In c language can we compile a program without main() function?

874


What is the best style for code layout in c?

862


Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1777


What is the use of header files?

857


Describe newline escape sequence with a sample program?

917


What is zero based addressing?

951


Is c is a high level language?

908


What is the difference between printf and scanf )?

833


The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this

3299


What are 3 types of structures?

864


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 }

2969


Can a pointer be volatile in c?

757


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15474


What is the difference between call by value and call by reference in c?

933