Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 are the Advantages of using macro

1128


What is the benefit of using const for declaring constants?

997


What are different types of pointers?

1022


What is a structure in c language. how to initialise a structure in c?

1032


In C programming, what command or code can be used to determine if a number of odd or even?

1007


Should I learn data structures in c or python?

989


Write a program to know whether the input number is an armstrong number.

1082


What header files do I need in order to define the standard library functions I use?

1013


What does c mean in standard form?

1116


What is a char c?

999


what is the structure pointer?

2084


Explain the term printf() and scanf() used in c language?

1012


What is a pointer in c plus plus?

1239


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

1065


Do you know the difference between exit() and _exit() function in c?

1024