write a program to find the given number is prime or not
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
What language is lisp written in?
what is the difference between declaration ,defenetion and initialization of a variable?
can a union be self-referenced?
what is difference between declaring the pointer as int and char in c language?
Write a program to print ASCII code for a given digit.
c program to print a name without using semicolon
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.
Explain c preprocessor?
Write a program of advanced Fibonacci series.
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
Using which language Test cases are added in .ptu file of RTRT unit testing???
What is the use of structure padding in c?