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 all the prime numbers with in the
given range

Answer Posted / roopa

#include<stdio.h>
#include <conio.h>


main()

{
int n1=0,n2=0;
printf("enter the range\n");
scanf("%d %d", &n1, &n2);
prime(n1,n2);
getch();
}

int prime(int n1, int n2)
{

int i,j;
for (i=n1;i<=n2;++i)

{
for(j=2;j<=(i/2);j++)
{
if(i%j==0)
{

break;
}
}
if(j==(i/2+1))
printf("%d\n", i);

}
}

Is This Answer Correct ?    31 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is null pointer in c?

960


What is %g in c?

1034


What is pointer to pointer in c with example?

1011


Can variables be declared anywhere in c?

1051


Explain how can I pad a string to a known length?

1150


How do you define structure?

1012


Explain how do you determine whether to use a stream function or a low-level function?

1046


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

1168


What is declaration and definition in c?

1041


Is there sort function in c?

979


What is the difference between mpi and openmp?

1235


please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................

1979


What are the 4 data types?

985


Explain how can I open a file so that other programs can update it at the same time?

1077


i have a written test for microland please give me test pattern

2691