answersLogoWhite

0

First10 prime number program

User Avatar

Anonymous

17y ago
Updated: 10/17/2024

Not tested:

void printPrimes(int n) {

int a = 0, b = 0;

float c = 0.0f;

bool isp = true;

int primes = 0;

while(true) {

a++;

do {

b++;

if(b > 1) {

c = (float)a/(float)b;

if(c = (int)c)

if(b != a) {

isp = false;

break;

}

else

isp=true;

}

} while(b<a);

if(isp) {

primes++;

std::cout << a << endl;

}

if(primes > n)

break;

b = 0;

c = 0;

isp = true;

}

}

void main() {

printPrimes(10);

}

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

A program to find that the input number is prime or not?

Use Wolfram|Alpha... go to the related link below, Wolfram|Alpha, and type in (is __ (number) prime) and then the program will compute that and tell you if it is prime or composite.


What is the largest prime no that is stored in 8 bit pattern?

Write your own prime number program and find out.


What is the code of a c program that will read in a positive integer value and determine If the integer is a prime number and If the integer is a Fibonacci number?

see the program


Prime numbers between 1 to 10 in microprocessor 8085?

program to find prime number in 8085 microprocessor


Write a java program to display the number is prime or not?

Simply use a for loop (i) that runs from 2 to N-1. Checking if N % i 0 then its a prime number.


With a given big integer number which is the product of two prime numbers how do you find them?

First write a program to generate the prime number. After one prime number was generated, divide the big int number by the prime number. If the remainder is zero then quotient is the second prime number ( also it is important to check whether the quotient is prime number or not because sometimes you will get wrong answer). Repeat the process until you get the result.


What is the Program for composite and prime numbers in c?

#include&lt;iostream.h&gt; #include&lt;conio.h&gt; int main() { int i,n; clrscr(); cout&lt;&lt;"PROGRAM TO CHECK IF THE NUMBER IS PRIME OR NOT:"&lt;&lt;endl; cout&lt;&lt;"Enter a number:"; cin&gt;&gt;n; for(int i=2;i&lt;n;i++) { if(n%i==0) cout&lt;&lt;"\nTHE NUMBER IS COMPOSITE"&lt;&lt;endl; else cout&lt;&lt;"\nTHE NUMBER IS PRIME"&lt;&lt;endl; } return 0; }


Shell program to generate prime number between 1 and 50?

There are several shell programs available for download on the Internet that will generate prime numbers. The best way to find a prime number is through calculation, however.


How do you program if it is a prime or composite?

The easiest, but not the most efficient way, to program this is to take your number "n" and test all the numbers from 2 to n-1 to see if they divide n, if none of them do, then n is prime.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


Program for print prime all number from 1 to 100 in foxpro?

Oh, what a lovely request! In FoxPro, you can create a program to print all prime numbers from 1 to 100 by using a loop to check each number for divisibility only by 1 and itself. If it meets this criteria, you can print it out on the screen. Remember, every number is unique and special, just like a happy little tree in a vast forest.


How can you check whether a number is prime or not by a C program using functions?

#include&lt;iostream.h&gt; #include&lt;conio.h&gt; void prime(int n) { clrscr(); int num; cout&lt;&lt;"enter the numbers"&lt;&lt;endl; cin&gt;&gt;num; prime(num); getch(); } void prime(int n) { int prime=1,i; for(i=2;i&lt;=n/2;i++) if(n%i==1) prime=0; if(prime==1) cout&lt;&lt;"the number"&lt;&lt;n&gt;&gt;"is prime"; else cout&lt;&lt;"the number"&lt;&lt;n&lt;&lt;"is not prime"; }