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 is #line?
Which programming language is best for getting job 2020?
Is anything faster than c?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
How can I get the current date or time of day in a c program?
Write a program to check armstrong number in c?
What does int main () mean?
What does the error 'Null Pointer Assignment' mean and what causes this error?
What are the primitive data types in c?
application attempts to perform an operation?
what are the facialities provided by you after the selection of the student.
What is the size of array float a(10)?
What is a static variable in c?
What is the use of gets and puts?
Can you add pointers together? Why would you?