| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to create a program that will decipher whether a number is prime or composite. I am hitting a few roadblocks. First of all .net will not allow me to use the sqrt() command, but yet when I put in the same exact code into Visual Studio 6.0 it allows me to do so, what command can I use in .net to allow me to create this program.
This is what I have so far (mind all of you, I am a college student just getting into the C++ programming field, I have basic and java knowlegde, so I am not totally oblivious) #include <iostream> #include <cmath> using namespace std; int main() { int i = 2; int x; cout << "Enter an interger and this program will tell whether it is prime or composite. " << endl; cin >> x; while (i <= sqrt(x)) cout << system("PAUSE") return 0 } Now the professor is saying that we have to use the sqrt() command for this program, I have figured out how to create a program that will decipher prime by using for loops with an if/else inside the for loop. Any help would be GREATLY APPRECIATE and thanks in advance, Chris |
|
#2
|
|||
|
|||
|
Oh and FYI i cannot even put the following code into C++
cout << sqrt(9) << endl; even that will not work |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Using C++ in .net and the sqrt() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|