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
Explain logical errors? Compare with syntax errors.
shorting algorithmS
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
Write a program for Overriding.
How do you override a defined macro?
How can I read data from data files with particular formats?
What is function and its example?
How do I use strcmp?
Describe newline escape sequence with a sample program?
What does 2n 4c mean?
explain what is a newline escape sequence?
What is extern storage class in c?
Can a pointer be static?
What are the scope of static variables?
Explain how can I manipulate strings of multibyte characters?