why wont this compile?

/ This program will calculate the prime numbers from 1 to 1000.
#include <iostream>
using namespace std;
int main()

{
double first; // To hold the first input
double second; // To hold the second input

//Get the input from the user
cout << "Enter a whole number between 1 and 1000" << endl;
cin >> first >> endl;
cout << "Enter a second whole number between 1 and 1000" << endl;
cin >> second >> endl;

//Calculate the entered data
if (first / 2)
cout << first << "is a prime number" << endl;
else
cout << first << "is not a prime number" << endl;
if (second / 2)
cout << second << "is a prime number" << endl;
else
cout << second << "is not a prime number" << endl;

return 0;
}
errors:usr/include/c++/4.4/istream:202: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.4/istream:206: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.4/istream:210: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.4/istream:214: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.4/istream:238: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.4/istream:741: note: std::basic_istream<_CharT2, _Traits2>& std::operator>>(std::basic_istream<_CharT2, _Traits2>&, _CharT2*) [with _CharT2 = char, _Traits2 = std::char_traits<char>, _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.4/bits/istream.tcc:853: note: std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&) [with _CharT = char, _Traits = std::char_traits<char>]
What compiler are you using? By the way your program logic is extremely flawed.

EDIT: See ne555's post below. I missed that.
Last edited on
c++. pico editor. I just need it to compile. Why isn't it working. I need it to say this;

Enter a number between 1 and 1000
*get that number and store it in 'first'
then i need it tosay
enter a second number between 1 and 1000
*get number and store it in 'second'
then I need a if statement that says
if the number they put in (first or second)
is divisible by 2 then shoot back the number they put in to them and let them know if it is prime or not.
Can you compile this?
1
2
3
4
5
6
7
#include <iostream>
int main()
{
    std::cout << "Hello, sweezy!" << std::endl;
    int x;
    std::cin >> x;
}
If you cannot, I suggest you get a modern compiler, as this code should compile.


EDIT: See ne555's post below. I missed that.
Last edited on
cin >> first >> endl;
¿what do you want to store in endl?
Topic archived. No new replies allowed.