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
What does do in c?
What is pragma in c?
What are local static variables? How can you use them?
What is the use of linkage in c language?
What is %d used for?
Explain how are 16- and 32-bit numbers stored?
Explain how can I write functions that take a variable number of arguments?
What is the difference between null pointer and wild pointer?
Which one would you prefer - a macro or a function?
Explain what is a 'locale'?
What is file in c language?
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
What is string constants?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
Differentiate between full, complete & perfect binary trees.