Write a program to find whether the given number is prime or
not?
Answer Posted / nikhilreddy gujjula
#include<stdio.h>
#include<conio.h>
void main()
{
int prime=1;
int n,i;
printf("enter a number");
scanf("%d",&n);
if(i=2;i<=n/2;i++)
{
if((n%i)==0)
{
prime=0;
break;
}
}
if(prime==1)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}
| Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
Why we use void main in c?
What do you mean by scope of a variable in c?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
What is the sizeof () a pointer?
Explain what is the best way to comment out a section of code that contains comments?
Do you know the difference between malloc() and calloc() function?
How do you determine whether to use a stream function or a low-level function?
How can I find out how much free space is available on disk?
What does *p++ do? What does it point to?
what is use of malloc and calloc?
What is a constant and types of constants in c?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Why is #define used?
List the different types of c tokens?
What is the difference between test design and test case design?