write the 10 prime nos program in c++?
Answer / Anjani Kumar Sinha
To write a C++ program to find the first ten prime numbers, you can use the following code:```cppn#include <iostream>nusing namespace std;nvoid printPrimes(int n) {n bool isPrime[n + 1]; // boolean array to store if a number is primenfill(isPrime, isPrime + n + 1, true); // init all numbers as primenfor (int p = 2; p * p <= n; ++p) {n for (int i = p * p; i <= n; i += p) {n isPrime[i] = false;n }n}nfor (int p = 2, count = 0; p <= n; ++p) {n if (isPrime[p]) {n cout << p << " ";n ++count;n if (count == 10) return;n }n}n}
| Is This Answer Correct ? | 0 Yes | 0 No |
i am fresher for giving intervivew in it sector and also sales electronics. all about related qustions send me please?
Name the two forms of boolean expression?
What are the advantages of gto over scr?
write a c program to multi(*) of two matrix using pointers?
In 8086 why even address location takes two bus cycles whereas odd address location takes only one bus cycle??
what is the source of time varying magnetic field?
what is the properties of good transformer oil
Why opamp called direct coupled high differential circuit?
where you wants to see you after 5 year?
How to manufacture the cmos inverter?
can anybody mail the exact sylabuss for ECIL
Explain digital circuits?
Civil Engineering (5086)
Mechanical Engineering (4453)
Electrical Engineering (16638)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)