write the program for prime numbers?
Answer Posted / awais
A PROG TO CHECK ANY NUMBER IS PRIME OR NOT BY USING IF ELSE STATEMENT
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter number");
scanf("%d",&x);
if(x==1)
{
printf("the number is neither composite nor prime");
}
else if(x==2)
{
printf("the number is prime");
}
else if(x%2==0)
{
printf("the number is not prime");
}
else if(x%2!=0)
{
printf("the number is prime");
}
getch();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is substring in c?
Is exit(status) truly equivalent to returning the same status from main?
How do you override a defined macro?
Can variables be declared anywhere in c?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What is a memory leak? How to avoid it?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
List the difference between a "copy constructor" and a "assignment operator"?
Explain the use of 'auto' keyword
Why is python slower than c?
What's the right way to use errno?
how to find anagram without using string functions using only loops in c programming
What is && in c programming?
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none