User Profile

Collapse

Profile Sidebar

Collapse
Trev17
Trev17
Last Activity: Apr 22 '09, 04:17 AM
Joined: Feb 12 '07
Location: Michigan
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Trev17
    replied to Problem with input and hashes
    in Perl
    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?
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Problem with input and hashes
    in Perl
    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' =>
    ...
    See more | Go to post
    Last edited by eWish; Apr 21 '09, 11:38 PM. Reason: Please use the [code][/code] tags

    Leave a comment:


  • Trev17
    started a topic Problem with input and hashes
    in Perl

    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'
    ...
    See more | Go to post
    Last edited by eWish; Apr 21 '09, 08:15 PM. Reason: Please use the code tags

  • Trev17
    replied to Function/Array problems
    in C
    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....
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Function/Array problems
    in C
    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?...
    See more | Go to post

    Leave a comment:


  • Trev17
    started a topic Function/Array problems
    in C

    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...
    See more | Go to post
    Last edited by sicarie; Apr 23 '07, 03:04 PM. Reason: Please use [code] and [/code] tags around your code.

  • Trev17
    replied to Compiling problems
    in C
    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*...
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    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?
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    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 +=...
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    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 numbers
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    what if the int typed in is negative? wont it execute the else?...
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    The program itself doesn't stop, but it just goes to the next line without printing anything...
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    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;
    }
    ...
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    thanks for the help guys. Is a while statement what i should be using or should I be using an if statement.
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    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.
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    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....
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to Compiling problems
    in C
    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.
    See more | Go to post

    Leave a comment:


  • Trev17
    started a topic Compiling problems
    in C

    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
    ...
    See more | Go to post
    Last edited by sicarie; Feb 20 '07, 02:37 AM. Reason: Added code tags.

  • Trev17
    replied to quadratic equation program
    in C
    it works, thanks for the help
    See more | Go to post

    Leave a comment:


  • Trev17
    replied to quadratic equation program
    in C
    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[])
    {
    ...
    See more | Go to post
    Last edited by sicarie; Feb 12 '07, 11:08 PM. Reason: Added code tags

    Leave a comment:

No activity results to display
Show More
Working...