how to find the given number is prime or not?
Answer Posted / rajamanickam.m
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,flag=0,ctr;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=sqrt(n);ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==0)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
Difference between exit() and _exit() function?
C program to find all possible outcomes of a dice?
which type of aspect you want from the student.
What happens if header file is included twice?
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;i
What are examples of structures?
How to define structures? ·
What are operators in c?
hi any body pls give me company name interview conduct "c" language only
How do I use strcmp?
Calculate 1*2*3*____*n using recursive function??
What does. int *x[](); means ?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
How do you list files in a directory?
Write the control statements in C language