answersLogoWhite

0


Best Answer

main()

{

int i,n,p,v;

printf("enter the number of terms");

scanf("%d",&n);

for(i=2;i<=n;i++)

{

for(j=1;j<i;j++)

{

if(i%j==0)

v=v+1;

else

p=p+1;

}

}

printf("%d is a prime",i);

}

check this out

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

#include<stdio.h>

#include<math.h>

bool is_prime (const unsigned num) {

if (num<2) return false;

if (!(num%2)) return num==2;

const unsigned max = sqrt (num) + 1;

for (unsigned div=3; div<max; div+=2) {

if (!(num%div)) return false;

}

return true;

}

int main (void) {

const unsigned min = 1;

const unsigned max = 1000;

printf ("Prime numbers in the range %d to %d\n", min, max);

for (unsigned n=min; n<=max; ++n) {

if (is_prime (n)) printf ("%d\n", n);

}

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

For primes, use printf with %d. For other integers, use printf with %d.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do write a program to output prime numbers between 1-1000 using c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Which best between 415v and 11000V generator of 2MW?

11000 V generator is best as it generates higher Voltage Profits: 1. Fuel saving, 2. Place Saving, 3. Less Pollution, 4. 11000 V can be step down as per requirement using modern equipments. 5. Least maintenance, Losses: As single unit generator 11000 V, if there is Break-down, all Collapse. And in 415 V multiple units are using so effect of Break down less, and easy maintenance. there might be less effect of B.D.


How much voltage is induce in choke while starting 1 phase fluroscent tube?

11000 volts


How Core Loss is dependent on Frequency?

since at no load only excitation current(responsible for core loss ie iron loss) flow on the primary side so core loss current will be 1A and core loss = v1*i1*powerfactor. core loss = 1*11000*0.24= 2640watt.


What is percent of power loss at 415 volts against 11000 volts?

Power = voltage times current, and the power loss is the loss in the line, I^2 * R. At 11,000 volts, the current will be (11,000 / 415 = ) 3.77% of what it is at 415 volts. So the power loss in the line at 11,000 volts will be (3.77% ^2 = ) .14% of what it is at 415 volts.


What safety precautions should be taken during maintanence of a 11000 volt line?

11 kV power lines are extremely dangerous and there are many safety requirements. The main principle is that this work must be done by trained and qualified personnel. Some of the protocols include always wearing a hardhat and protective boots, and never going near such power alone.