I just started learning c++ this week, and as such, I dont yet have a great understanding of really anything xD. I know that there are errors galore in this program, but i dont really know where to look, as the build output isnt helping at all. I'd appreciate any feedback whatsoever =D
(btw, its supposed to be something of a calculator program in win32 console)
// uniq1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include <iostream>
int main()
{
using namespace std;
float x,z;
int y;
cout<< "Enter a decimal x" <<endl;
cout<< "x: " ;
cin>> x <<endl;
cout<< "Enter the number that corresponds to the operation you would like to use" <<endl;
cou<<t "1. +" <<endl;
cout<< "2. -" <<endl;
cout<< "3. *" <<endl;
cout<< "4. /" <<endl;
cout<< "5. % (modulus)"<< endl;
cin>> y <<endl;
cout<< "Now enter the factor by which x will be multiplied/added to/ subtracted by etc...";
cout<< "z: ";
cin>> z;
if ( y == 1 )
{ cout<< x+z;
}
else if (y == 2)
{cout<< x-z;
}
else if (y == 3)
{cout<< x*z;
}
else if (y == 4)
{cout<< x/z;
}
else if (y == 5)
{ cout<< x%z;
}
else
{cout<< "You have entered an invalid operation value choice.";
2) The build output may not help you yet, but it helps us. Give us the errors you're getting so we can explain to you what they mean and how to fix them. Makes it easier to find and fix the problem.
3) don't use << endl with cin.
4) don't have _tmain() and main() in the same program -- pick one. I recommend using main() (_tmain is a silly nonstandard extension)
That's all I can see off the bat. Like I say an error list would help.
// uniq1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include <iostream>
int main()
{
usingnamespace std;
float x,z;
int y;
cout<< "Enter a decimal x" <<endl;
cout<< "x: " ;
cin>> x ;
cout<< "Enter the number that corresponds to the operation you would like to use" <<endl;
cout<< "1. +" <<endl;
cout<< "2. - (will find the positive difference)" <<endl;
cout<< "3. *" <<endl;
cout<< "4. /" <<endl;
//cout<< "5. % "<< endl; (I took this one out cos you can't use modulus with floats)
cin>> y ;
cout<< "Now enter the factor by which x will be multiplied/added to/ subtracted by etc...";
cout<< "z: ";
cin>> z;
if ( y == 1 )
{ cout<< x+z <<endl;
}
elseif (y == 2)
{
if (x>=z)
{cout<< x-z <<endl;}
else
cout<< z-x <<endl;}
elseif (y == 3)
{cout<< x*z <<endl;
}
elseif (y == 4)
{cout<< x/z <<endl;
}
/*else if (y == 5)
{ cout<< x%z;
}
(I took this one out cos you can't use modulus with floats)*/
else
{cout<< "You have entered an invalid operation value choice." <<endl;
}
return 0;
}