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 


What is wrong with this code?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jun 22, 2007 10:34 pm    Post subject: What is wrong with this code? Reply with quote

Ok, well I wanted to make a farenheit to celcius converter and vise versa. But there seems to be something wrong with my code that I just can't seem to fix. So, can you guys help me with it? Here is the code. Btw it is in pascal. Now I know you guys know delphi, so this shouldn't be that hard...

Code:

program FarenheitToCelcius_CelciusToFarenheit;

uses crt;

var i : char;

  procedure FarenheitToCelcius;
  var F,C : integer;
  begin
  clrscr;
  writeln('Please enter the temperature in farenheit.');
  readln(F);
  C:=(F-32)*5/9;
  writeln('The temperature in celcius is ',C,'.');
  readln;
  end;

  procedure CelciusToFarenheit;
  var F,C : integer;
  clrscr;
  writeln('Please enter the temperature in celcius.');
  readln(C);
  F:=(C*9)/5+32;
  writeln('The temperature in farenheit is ',F,'.');
  readln;
  end;

begin
var F,C : string;
    i : char;
F:='F';
C:='C';
clrscr;
writeln('Welcome to the Temperature Converter by oib.');
writeln('If you would like to convert farenheit to celcius press F.');
writeln('If you would like to convert celcius to farenheit press C.');
readln(i);
if (i<>'F') and (i<>'C') then
  begin
  writeln('Invalid choice, your choices are F and C.');
  end;
else if (i = 'F') then
  begin
  FarenheitToCelcius;
  end;
else
  begin
  CelciusToFarenheit;
  end;
end.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Fri Jun 22, 2007 10:37 pm    Post subject: Reply with quote

you shouldn't be using integers for this.
Back to top
View user's profile Send private message
SkatSkat
Grandmaster Cheater
Reputation: 0

Joined: 30 Oct 2006
Posts: 648

PostPosted: Fri Jun 22, 2007 11:19 pm    Post subject: Reply with quote

What's the problem?
_________________
"We're betting everything on ourselves tonight" - The Bouncing Souls
Back to top
View user's profile Send private message AIM Address
Uzeil
Moderator
Reputation: 6

Joined: 21 Oct 2006
Posts: 2411

PostPosted: Sat Jun 23, 2007 12:30 am    Post subject: Reply with quote

You use blocks for no apparent reason, you apply chars to string varables when they are neither used or necessary as STRINGs, you don't control what happens after the string for invalid input, and since the only difference is the math and string and you only call it from one location, you only need one algo that doesn't need to be seperated to a procedure and can be based on if statements depending on a boolean set by their input.

TADAA

_________________


Mini Engine v3.0
Mipla v1.0

Reposted old threads out of the MS section.
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