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

What is a macro in c preprocessor?

616


What is data types?

624


What are the 4 types of organizational structures?

613


What is an arrays?

642


Is c++ based on c?

640






What are the different data types in C?

716


Why is not a pointer null after calling free?

583


a program that can input number of records and can view it again the record

1474


What is c language used for?

550


How do I get an accurate error status return from system on ms-dos?

636


List the difference between a While & Do While loops?

625


Can we declare variable anywhere in c?

527


Why is struct padding needed?

621


How many data structures are there in c?

604


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

619