write a program to find the given number is prime or not

Answers were Sorted based on User's Feedback



write a program to find the given number is prime or not..

Answer / alex

here is answer
http://www.prepjunk.com/151/program-to-find-the-given-number-is-prime-or-not

Is This Answer Correct ?    2 Yes 0 No

write a program to find the given number is prime or not..

Answer / Satyaveer Singh

Here's an example C program that checks if a given number is prime:
```c
#include<stdio.h>
void checkPrime(int n) {
int i;
for (i = 2; i <= sqrt(n); ++i) {
if (n % i == 0) {
printf("%d is not a prime number.n", n);
return;
}
}
printf("%d is a prime number.n", n);
}
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
checkPrime(num);
return 0;
}
```

Is This Answer Correct ?    0 Yes 0 No

write a program to find the given number is prime or not..

Answer / rabindra nath das

#include<stdio.h>
#include<conio.h>
void main()
int n,k,fl=0,r;
clrscr();
printf("\n Enter the number==>>");
scanf("%d",&d);
for(k=2;k<=n/2 && fl==0;k++)
{
r=n%k;
if(r==0);
fl=1;
}
if(fl==0)
printf("\n %d is a prime number",n);
else
printf("\n %d is not prime number",n);
getch();
}

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More C Interview Questions

What language is lisp written in?

1 Answers  


what is the difference between declaration ,defenetion and initialization of a variable?

7 Answers   LG Soft,


can a union be self-referenced?

1 Answers  


what is difference between declaring the pointer as int and char in c language?

3 Answers  


Write a program to print ASCII code for a given digit.

1 Answers   EXL, HCL,


c program to print a name without using semicolon

9 Answers   TCS, Wipro,


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1 Answers  


Explain c preprocessor?

1 Answers  


Write a program of advanced Fibonacci series.

1 Answers   Aspiring Minds,


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

1 Answers  


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

1 Answers  


What is the use of structure padding in c?

1 Answers  


Categories