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 a macro in c preprocessor?
What is data types?
What are the 4 types of organizational structures?
What is an arrays?
Is c++ based on c?
What are the different data types in C?
Why is not a pointer null after calling free?
a program that can input number of records and can view it again the record
What is c language used for?
How do I get an accurate error status return from system on ms-dos?
List the difference between a While & Do While loops?
Can we declare variable anywhere in c?
Why is struct padding needed?
How many data structures are there in c?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference