User Profile
Collapse
-
Thanks Kevin! I found it works if i take off the strict and the warning. I don't know why i was getting those errors, maybe it was a local/global problem? -
Thank you for the reply Kevin. I really appreciate it. I changed a few things and i have added the use strict; and use warnings; to better help fix the problem. I modified my code to look like this:
Code:use strict; use warnings; %courses= ( '2CPR2B' => 'C Language', '1UNX1B' => 'Intro to UNIX', '3SH414' => 'Shell Programming', '4PL400' =>
Leave a comment:
-
Problem with input and hashes
Hello all,
I am in Perl programming class this term and am a beginner. I'm trying to be able to type any key of the hash i want using STDIN to pull the value of the key from the hash.
my program consists of this much so far.
Code:%courses= ( '2CPR2B' => 'C Language', '1UNX1B' => 'Intro to UNIX', '3SH414' => 'Shell Programming', '4PL400'
-
I changed it to this but now it sort of freezes after it calls the getData function.
while (File)
{
for (int row = 0; row < 12; row++)
for (int col = 0; col < 2; col++)
temps[row][col]++;
}
I think this is what you meant but not sure....Leave a comment:
-
I have both functions (averageHigh, averageLow) being called in the program and the output for both is 0. If thats what you meant?
for the if (!File) how would you put that in so that it does something?...Leave a comment:
-
Function/Array problems
Hello, I am trying to write a program that reads in a file, and uses a 2d array to store the highest and lowest temp from each month. It also outputs the average high and the average low. The file that i am reading in is called homework2.txt and looks like this:
-4 25
6 33
21 50
33 67
50 72
65 80
72 95
65 101
58 82
35 62
34 59
-6 31
the first column being...Last edited by sicarie; Apr 23 '07, 03:04 PM. Reason: Please use [code] and [/code] tags around your code. -
I fixed it, i changed while(num>0) to while(num) and i took out the rnum*= -1 at then end of the else statement. It seems to be outputting everything ok now.
I do have one more question, im suppost to have a slip of code in where it checks if you are putting in an integer amount. I have added code for this but it doesn't seem to be working properly, I have used this code for trying this:
int _tmain(int argc, _TCHAR*...Leave a comment:
-
i might be wrong on this but is it because there is no way for the else to ever work because its in the while which is greater than 0 to begin with.
If so, is it possible to just get rid of the while statement and just use the if statement?Leave a comment:
-
theres still a problem somewhere in my reverseDigits function. I think it has to do with what i'm declaring in the while statement but it keeps giving me 0 as the output for a negative reverse function.
int reverseDigit(in t rev)
{
int num = rev, rnum = 0, digit;
while (num>0)
{
if (num>0)
{
rnum *= 10;
digit = num % 10;
rnum +=...Leave a comment:
-
ahhh, that makes sense. so if i put the if statement like this:
if ((num>0) == true)
the else would make it false and the if statement would not come out true if i did input a negative. right?
With the above code in it still returns 0 for negative numbersLeave a comment:
-
what if the int typed in is negative? wont it execute the else?...Leave a comment:
-
The program itself doesn't stop, but it just goes to the next line without printing anything...Leave a comment:
-
I've done this but i am having a little problem somewhere in the code. It compiles, it just doesn't output anything after i put in the integer to be reversed.
int reverseDigit(in t rev)
{
int num = rev, rnum = 0, digit;
while (num>=0)
{
if (true)
{
rnum *= 10;
digit = num % 10;
rnum += digit;
num /= 10;
}
...Leave a comment:
-
thanks for the help guys. Is a while statement what i should be using or should I be using an if statement.Leave a comment:
-
Looking at this function, can you tell me when the second half will execute?[/QUOTE]
Doesn't the second half execute only if the number is negative? If it doesn't, i don't understand why.Leave a comment:
-
I know that in order to get the output to be negative and reverse i would do the same coding only multiply rnum and the end by -1 to make the reversed integer negative but i cant figure out how to do that....Leave a comment:
-
Wow, i feel like a complete idiot now haha. The good news is it did compile but the bad news is that every time i try to reverse a negative number i get 0.Leave a comment:
-
Compiling problems
Hello, i am getting numerous error messages when trying to compile my program. The program is to create a function to reverse digits. I have a feeling i am close but i can't figure out the problem. I'm getting a lot of errors regarding istreams and ostreams. I have been trying to figure this out for hours.
Code:#include "stdafx.h" #include <iostream> using namespace std; int reverseDigit(int
-
-
yeah, i changed the coding a little bit but i still get a syntax error for descrim. Also, i don't really understand how to set pow with a .5 value. Here are the changes i have made:
Code:#include "stdafx.h" #include <iostream> #include <cmath> #include <complex> using namespace std; int _tmain(int argc, _TCHAR* argv[]) {
Leave a comment:
No activity results to display
Show More
Leave a comment: