Nope. I totally don't get it. That's why I'm taking a beginning C++ class.
I did figure out the additional >> at the end and changed my code to:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
#include <cstdlib>
using namespace std;
int main () {
int num1; // This is the original number entered by the user.
int num2; // This is the second number entered if the first number is odd.
cout<< "Enter a number: "<<endl;
cin>>num1;
if (num1 % 2 == 0) {
cout<< num1<< " Your number is even." <<endl;
}
else {
cout<<num1<< " Your number is odd. Please enter another number: " <<endl;
cin>>num2;
cout<< " Your two numbers multiplied equals: " <<(num1*num2)<<endl;
}
} // end of main ()
|
Now I'm getting the following error:
021015_ltalon.out: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/../lib64/crt1.o:(.text+0x0): first defined here
021015_ltalon.out: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/../lib64/crti.o:(.fini+0x0): first defined here
021015_ltalon.out:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/../lib64/crt1.o:(.rodata.cst4+0x0): first defined here
021015_ltalon.out: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/../lib64/crt1.o:(.data+0x0): first defined here
021015_ltalon.out: In function `__data_start':
(.data+0x8): multiple definition of `__dso_handle'
/opt/gcc4.9.1/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/crtbegin.o:(.data+0x0): first defined here
021015_ltalon.out: In function `main':
(.text+0x168): multiple definition of `main'
/tmp/ccO3LJa2.o:021015_ltalon.cpp:(.text+0x0): first defined here
021015_ltalon.out: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/../lib64/crti.o:(.init+0x0): first defined here
/opt/gcc4.9.1/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
021015_ltalon.out:(.dtors+0x8): first defined here
/opt/gcc4.9.1/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
021015_ltalon.out:(.data+0x10): first defined here
/usr/bin/ld: error in 021015_ltalon.out(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
I have never gotten an error like this. It's an ugly one! The only thing I can think is that I'm not using the correct library? Am I close?