Ik ben bezig een klein programmaatje te maken in Visual studio maar als ik het wil uitvoeren krijg ik de volgende foutmeldingen te zien:
error: C2668: 'sqrt' : ambiguous call to overloaded function
error: IntelliSense: more than one instance of overloaded function "sqrt" matches the argument list:
Zie hieronder de code.. iemand die me hiermee kan helpen??
error: C2668: 'sqrt' : ambiguous call to overloaded function
error: IntelliSense: more than one instance of overloaded function "sqrt" matches the argument list:
Zie hieronder de code.. iemand die me hiermee kan helpen??
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| #include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int main()
int n; //number to test for prime-ness
int i; // Loop counter
int is_prime = true; //Boolean flag
// Assume true for now.
// Get a number from the keyboard.
cout << "Enter a number and press ENTER: ";
cin >> n;
// Test for prime by checking for divisbility
// By all whole numbers from 2 to sqrt(n)
i = 2;
while (i <= sqrt(n)) { // While i is <= sqrt(n),
if (n % i == 0) // If i divied n,
is_prime = false; // n is not prime.
i++; // Add 1 to i.
}
// Print results
if (is_prime)
cout << "Number is prime.";
else
cout << "Number is not prime.";
system("Pause");
return 0;
} |
[ Voor 4% gewijzigd door Verwijderd op 02-06-2013 02:06 ]