- Joined
- Jul 26, 2002
ok im writing this program for my c++ class, were supposed to aks the user how many times he wants the fibonacci sequence done. BUT i keep getting this error-
fib prog.obj : error LNK2005: _main already defined in 12.obj
Debug/p363.exe : fatal error LNK1169: one or more multiply defined symbols found
heres my code-
fib prog.obj : error LNK2005: _main already defined in 12.obj
Debug/p363.exe : fatal error LNK1169: one or more multiply defined symbols found
heres my code-
Code:
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <math.h>
//function declarations
int GetData();
void CalcFib(int seq);
int main()
{
int seq;
seq=GetData();
system ("CLS");
CalcFib(seq);
return 0;
}
int GetData()
{
/*
task:obtain 3 of times sequence must be done
Data in: nada
Data out: uno interger
*/
int seq;
do
{
cout<<"Enter ho wmany times you want the sequence done. "<<endl;
cin>>seq;
if(seq<0)
{
system("cls");
cout<<"YOU ENTERED A NEGATIVE NUMBER"<<endl;
}
}
while(seq<0);
return seq;
}
void CalcFib(int seq)
{
/*
task: display the sequence
Data in:# of desired sequences
Data out:nada
*/
int x, num1, num2, num3, nada;
num1=0;
num2=1;
cout<<"the number of times the sequence was done" << seq<<endl;
if(seq==1)
cout<<"0"<<endl;
else if(seq==2)
cout<< " " <<num1 << " " << num2;
else
{
cout<<" "<< num1 << " " << num2 << " ";
for(x=1; x<=(seq-2); x++)
{
num3=num1+num2;
cout<<num3<<endl;
nada=num2;
num2=nada;
}
}
cout<<endl<<endl;
}
Last edited by a moderator: