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


Please Help Members By Posting Answers For Below Questions

Why should I use standard library functions instead of writing my own?

676


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?

675


What does c mean in standard form?

601


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

602


What is c basic?

603






Is calloc better than malloc?

580


What is the use of #define preprocessor in c?

621


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

771


When should a far pointer be used?

607


What are the features of c languages?

633


How can you call a function, given its name as a string?

716


How many types of sorting are there in c?

616


How many bytes is a struct in c?

727


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

565


What are the 4 types of organizational structures?

627