Write a program to find whether the given number is prime or
not?
Answer Posted / md.ershad ezaz
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,c;
clrscr();
printf("Enter a number\n");
scanf("%d",&n);
c=0;
for(i=1;i<=n;i++)
{
if(n%i==0)
c=c+1;
}
if(c==2)
printf("%d is prime",n);
else
printf("%d is not prime",n);
getch();
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
Why c is called a middle level language?
Difference between Function to pointer and pointer to function
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
What is strcmp in c?
What are extern variables in c?
What are different storage class specifiers in c?
What is the use of gets and puts?
Write a program to implement queue.
i want to know the procedure of qualcomm for getting a job through offcampus
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
What is preprocessor with example?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What are void pointers in c?