Write a program to find whether the given number is prime or
not?
Answer Posted / padhmavathi loganathan
#include<stdio.h>
int main()
{
int a,i,f;
printf("Enter a number: ");
scanf("%d",&a);
f=0;
i=2;
while(i <= a/2)
{
if(a%i == 0)
{
f=1;
break;
}
i++;
}
if(f==0)
printf("Prime Number")
else
printf("Not Prime Number");
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
Why do we need functions in c?
What is chain pointer in c?
Explain how are portions of a program disabled in demo versions?
Write a program to print factorial of given number without using recursion?
How does sizeof know array size?
What is the use of a conditional inclusion statement in C?
What is operator promotion?
How #define works?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
What is scope of variable in c?
What are the different types of errors?
What is string length in c?
What is restrict keyword in c?
Is it possible to initialize a variable at the time it was declared?