answersLogoWhite

0


Best Answer


#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

14y ago
This answer is:
User Avatar

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.

Related questions

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


Consider prime numbers between 1 and 10000. Draw a flowchart to display the prime numbers.Write a pseudo code associated with the flowchart in a)?

A) Here's an example of a flowchart and pseudocode that could be used to display the prime numbers between 1 and 10000: Flowchart:
START Set up an array of numbers from 1 to 10000 Set an empty array to store the prime numbers Set i = 2, the first prime number For each number in the array, check if it is divisible by i If it is divisible by i, it is not a prime number and move to the next number in the array If it is not divisible by i, it is a prime number and add it to the prime numbers array Increase i by 1 and go back to step 4 Repeat steps 4 through 7 until i is greater than the square root of 10000 Display the prime numbers array END


How to write Morse code?

To write Morse code, use a combination of short and long signals, known as dots and dashes, respectively, to represent letters, numbers, and punctuation marks, with a short pause between each element. You can write with Morse code translators as well. If you want to learn proper Morse code then you'll need to start with Morse code alphabets first.


How do you write a matlab code to check if a random number is prime or not?

My Code: ======================================&hellip; &gt;&gt; disp('input a pair of natural numbers, N and M with M&gt;N'); N=input('N='); M=input('M='); for j=0:(M-N) Prime=1; for i=2:((N+j)/2) if mod((N+j),i)==0 Prime=0; break end end if Prime==1 disp('This is a Prime Number'); else disp('Not Prime'); end end


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.


What does the dr call the sequence of numbers that riley used to break the trip code?

happy prime


What is the symbol used between two code numbers to indicate that a range is available?

The symbol used between two code numbers to indicate that a range is available is a


How do you write a program to print prime numbers from 1 to 50 in PHP?

The following PHP Code will display the prime numbers between 2 and 50.You know that 1 is not a prime number so edit the value for "first for loop" according to your requirements (you can also do it for 2 to 1000 or from 900 to 929)Output will be:2is a prime number3is a prime number5is a prime number7is a prime number11is a prime number13is a prime number17is a prime number19is a prime number23is a prime number29is a prime number31is a prime number37is a prime number41is a prime number43is a prime number47is a prime number2013-02-22: Replaced $i/2 with sqrt($i) for efficiency by Ryankirgan


Why is 37 a prime number?

A prime number is a number that is can only be divided by one and itself. 37 can be divided by no smaller whole number other than one. As numbers get larger, fewer and fewer of them are prime numbers because more and more of them can be divided by whole numbers. 39 is not a prime number. It can be divided by 3 and 13. 91 is not a prime number. It can be divided by 7 and 13. Prime numbers are important in secret communications. A value for each letter is multiplied by two prime numbers with several billion digits. It is difficult for anyone to break the code.