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

Explain what is the best way to comment out a section of code that contains comments?

1128


What is infinite loop?

1076


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

2213


Discuss the function of conditional operator, size of operator and comma operator with examples.

1145


What is #ifdef ? What is its application?

1091


How do you generate random numbers in C?

1181


Why doesn't C support function overloading?

2718


What is structure of c program?

1142


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

1055


Explain enumerated types.

1020


What is keyword in c?

996


Explain how many levels deep can include files be nested?

1061


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

1050


In a byte, what is the maximum decimal number that you can accommodate?

1123


When should structures be passed by values or by references?

1031