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

I hope this is right code for you
1st it promt for max number then enter 500 then you will
get result.


#include<stdio.h>
#include<conio.h>
int main()
{
int value,j,i,value2,flag=0,count=0;
clrscr();
printf("enter limit up to which prime numbers to be
printed : ");
scanf("%d",&value2);
printf("\n\n\nlist of prime numbers are:\n\n");
for(j=1;j<=value2;j++)
{
flag=0;
value=j;
for(i=2;i<value;i++)
{
if(value%i==0)
{

flag=flag+1;
goto l1;

}


}
l1:
if(!(flag==1||value==2))
{
printf("%-10d",value);
count+=1;
}
}
printf("\n\ntotal number of prime numbers between 1 and %d
are : %d",value2,count);
getch();
return 0;

}



if their is any changes required or any suggestions mail
me at molugu.ashwin@gmail.com

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different file extensions involved when programming in C?

1205


Explain how do you list a file’s date and time?

988


What is header file definition?

1024


What is %s and %d in c?

973


What is c basic?

1124


Explain what is the difference between a free-standing and a hosted environment?

1126


What is difference between union All statement and Union?

1058


Explain 'bus error'?

1013


Here is a good puzzle: how do you write a program which produces its own source code as output?

1035


What does sizeof function do?

1125


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

2306


hi, which software companys will take,if d candidate's % is jst 55%?

2047


What is difference between main and void main?

1116


What is meant by inheritance?

1048


How can a number be converted to a string?

1240