I am having a problem with my program. We are supposed to ask for two numbers as input then half the larger and double the smaller. If the larger is odd then the smaller is added to an accumulator.
My problem lies (i'm guessing) somewhere in the functions.
Here is my code and below is my compile error.
/* Program Name:multiplication.cpp
Description: Program does reverse multiplication
Name:Scott Streit Class No.: 4467
Date:11/09/09 VisualC++
*/
//********************************** Includes
#include <cfloat>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cctype>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>
#include <conio.h>
#include <windows.h>
#include <sstream>
#define cls system("cls")
#define frz system("pause");
#define yl system("color 0e");
using namespace std;
//********************************** Type definitions
ofstream print("i:\\c++\\multiplication.txt");
//********************************** Function Prototypes
void input(int &nnum1, int &nnum2);
void findbig(int nnum1,int nnum2, int &bbig,int &ssmall);
void math(int bbig, int ssmall, int &ttotal);
void display();
//********************************** Main Function
int main()
{
time_t t;
time(&t);
yl;
cls;
int num1, num2, big, small;
int total=0;
input(num1, num2);
findbig(num1, num2, big, small);
math(big, small, total);
display();
frz;
return 0;
} // end of main function
//********************************** Function Definitions
void input(int &nnum1, int &nnum2)
{
cout<<"Please enter your first number: ";
cin>>nnum1;
cout<<"Please enter your second number: ";
cin>>nnum2;
}//end input
void findbig(int nnum1, int nnum2,int bbig, int ssmall)
{
if(nnum1>nnum2)
{
bbig=nnum1;
ssmall=nnum2;
}
else
{
bbig=nnum2;
ssmall=nnum1;
}
cout<<bbig<<"\n";
}//end findbig
void math(int bbig, int ssmall, int ttotal)
{
ttotal=0;
while (bbig!=0)
{
if (bbig%2==0)
{
(bbig/2);
(ssmall*2);
}//end if
else
{
ttotal+=ssmall;
(bbig/(2));
(ssmall*(2));
}//end else
}//end while
cout<<(bbig*ssmall)<<"\n";
cout<<ttotal<<"\n";
}//end math
void display()
{
cout<<"at display\n";
}//end display
Here is the compiler error.
1>------ Build started: Project: multiplication, Configuration: Debug Win32 ------
1>Compiling...
1>multiplication.cpp
1>i:\c++\multiplication\multiplication\multiplication.cpp(45) : error C2062: type 'char' unexpected
1>i:\c++\multiplication\multiplication\multiplication.cpp(49) : error C2062: type 'char' unexpected
1>i:\c++\multiplication\multiplication\multiplication.cpp(50) : error C2062: type 'char' unexpected
1>Build log was saved at "file://i:\c++\multiplication\multiplication\Debug\BuildLog.htm"
1>multiplication - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========