i want to asked a question about c program the question is:
create a c program that displays all prime numbers less than
500? using looping statement
Answer Posted / ashwin kumar
its just to find weather given number is prime or not
#include<stdio.h>
#include<conio.h>
int main()
{
int value,i,flag=0;
clrscr();
printf("enter value to check for prime number : ");
scanf("%d",&value);
for(i=2;i<value;i++)
{
if(value%i==0)
{
flag=flag+1;
break;
}
}
if(flag==1||value==2)
printf(" %d is not a prime number",value);
else
printf(" %d is a prime number",value);
getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are the Advantages of using macro
What is the benefit of using const for declaring constants?
What are different types of pointers?
What is a structure in c language. how to initialise a structure in c?
In C programming, what command or code can be used to determine if a number of odd or even?
Should I learn data structures in c or python?
Write a program to know whether the input number is an armstrong number.
What header files do I need in order to define the standard library functions I use?
What does c mean in standard form?
What is a char c?
what is the structure pointer?
Explain the term printf() and scanf() used in c language?
What is a pointer in c plus plus?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
Do you know the difference between exit() and _exit() function in c?