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
Why should I use standard library functions instead of writing my own?
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
What does c mean in standard form?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
What is c basic?
Is calloc better than malloc?
What is the use of #define preprocessor in c?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
When should a far pointer be used?
What are the features of c languages?
How can you call a function, given its name as a string?
How many types of sorting are there in c?
How many bytes is a struct in c?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What are the 4 types of organizational structures?