answersLogoWhite

0


#include
#include

void main()

{
int i;

for(i=1;i<51;i++)
{
if IsPrime(i)
printf("%d, ", i);
}
}

bool IsPrime(int i)
{
int c;

for(c=2;c{
if(i % c = 0)
return false;
}
return true;
}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

BeauBeau
You're doing better than you think!
Chat with Beau
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: Write code for prime numbers between 1 to 50 in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

How do you write a vbscript code for displaying the prime numbers between 1 and 100?

Option ExplicitDim i,j,var,Flag,nvar=""n=cint(InputBox("Enter nth Number to check Prime Numbers"))i = 3While i


Why are prime numbers used in code creations?

I use prime numbers in code to catalog things with one number. I assign a prime number to a certain characteristic. Then I multiply together the prime numbers for each characteristic contained. Later, that number can be divided a prime number. If a remainder of zero is returned I know it contains the number and what too associate it with.


Write a pseudo code to display prime numbers from 1-1000?

loop i from 0 to num check if num mod i equals 0breakelsesum = sum + numend the loopprint the sum


What are a dozen or more facts about prime numbers?

1 Prime numbers have only 2 factors which are themselves and one 2 Prime numbers can't be composite numbers which have more than 2 factors 3 Prime numbers are odd except for two which is the only even prime number 4 Prime numbers are used in finding the LCM of 2 or more numbers 5 Prime numbers are used in finding the HCF of 2 or more numbers 6 Prime numbers are used in finding the LCD of fractions 7 Prime numbers are used in reducing fraction to their lowest terms 8 Prime numbers are rational because they can be expressed as fractions 9 Prime numbers are infinite 10 Prime numbers are irrational when square rooted 11 Prime numbers can't be 0 or 1 which are also not composite numbers 12 Prime numbers don't follow a forecasted numerical pattern 13 Prime numbers make up 25% of the first 100 integers or whole numbers 14 Prime numbers have a code amongst themselves that has never been cracked


Why do prime numbers matter?

Prime numbers are important for several applications, such as cryptography and information technology. They are also useful for some simpler tasks in mathematics (for example, finding the common factors of two numbers). Prime numbers are usefull in encryption because code breaking computers employ search algorithms that keep multiplying numbers together In order to find a combination to break the code, but if you have a very large prome, the code breaker probably won't find it. The Unique-Prime-Factorization Theorem is so useful, that it is also called the Fundamental Theorem of Arithmetic.