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...

Write a program to print the prime numbers from 1 to 100?

Answer Posted / m santhosh

int count=0;
int number=100; //// print Prime no's from 1 to 100
for(int i=1;i<=number;i++)
{
count=0;
for(int j=1;j<=i;j++)
{
if((i%j==0))
{
count++;
}

}
if(count<=2)
{
printf("\nPrime Number = %d",i);

}

}

Is This Answer Correct ?    14 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is meant by 'bit masking'?

1183


Where are some collections of useful code fragments and examples?

1146


Differentiate between calloc and malloc.

1249


What type is sizeof?

1028


What is the use of getchar functions?

1169


What is identifier in c?

1002


What are the ways to a null pointer can use in c programming language?

1119


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

1080


What is variable initialization and why is it important?

1234


What are the back slash character constants or escape sequence charactersavailable in c?

1165


What is meant by operator precedence?

1127


What does main () mean in c?

1086


What the different types of arrays in c?

1052


What is spaghetti programming?

1110


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

1051