Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ "%" operan/operator

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
TheZaw
Valve mod
Reputation: 0

Joined: 01 Mar 2008
Posts: 1061
Location: Learning C++

PostPosted: Sat Apr 05, 2008 12:06 am    Post subject: C++ "%" operan/operator Reply with quote

Heya people! Im making a merchenting counculator (challenge from my brother) and i need a way to get remainders. He gave me a hint that the "%" operator divides and returns the remainder. I can't get it to work for me, as it returns false.

Heres my code btw, fully commented. Oh, and its not finished yet, as im stuck on this stage. Also, no goto deathbydinousour for me! (if you don't get that, go here: http://xkcd.com/292/)
#include <iostream>
using namespace std;

int goal, current, buy, sell;//declaring integers for use

int profitper, c, d, e, f; //integers used in the math part
int itemsper(int buy, int current);//function for returning items available with current cash


int main(){//main part of program


cout<<"Enter current money available for merchenting: ";
cin>>current;//gets current money for merchenting. Cout stands for console (keyboard) out. Cin stands for console in.
cin.ignore();//ignores enter, so cin.get doesn't trigger.

cout<<"Enter goal for total cash at end of merchenting: ";
cin>>goal;//Gets Goal for cash
cin.get();

cout<<"How much are you buying the item for: ";
cin>>buy;//gets how much to buy item for
cin.get();

cout<<"How much are you going to sell the item for: ";
cin>>sell;
cin.ignore();

itemsper(buy, current);

while (current<goal){//while current money is less than goal do this
profitper=sell-buy;//gets profit per item







}


cin.get();//when finished, press enter to terminate program
}


int itemsper(int buy, int current){
int temporary, temp2;//these integers will be thrown away later, just needed to store temporary values

temporary=current/buy;

temp2=current%buy;//the "%" operator returns the remainder of the divisor
if(temp2=0){
temporary=temporary-1;
}

cout<<temp2;

}

_________________
Back to top
View user's profile Send private message MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sat Apr 05, 2008 2:23 pm    Post subject: Reply with quote

Code:
if(temp2=0){

There's your problem
Back to top
View user's profile Send private message
TheZaw
Valve mod
Reputation: 0

Joined: 01 Mar 2008
Posts: 1061
Location: Learning C++

PostPosted: Sat Apr 05, 2008 3:38 pm    Post subject: Reply with quote

it should be if(temp2==0)?
_________________
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Apr 05, 2008 3:42 pm    Post subject: Reply with quote

= is assignment

== is comparison
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites