Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 08-20-2012, 08:31 AM   #101
fluffheadsr
adept
 
Join Date: May 2012
Posts: 714
Re: Masters In Comp Sci With No Prior Experience

Build yourself an amazing portfolio to really show off your skills and it wont matter where you went to school one iota.
fluffheadsr is offline   Reply With Quote
Old 08-29-2012, 05:32 PM   #102
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

I am working on an assignment from last semester as practice before classes start. I'm trying to do it in a different way than I did last time. Does anyone know why this isn't working? By isn't working I mean the output is incorrect.

The goal of the code is to say whether two sequences of numbers are identical.

Code:
import java.util.*;
public class Order
{
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in); 
    int s;
    int t; 
System.out.println("Enter a sequence of positive integers"); 
s = input.nextInt(); 
 int[ ] nums = new int [s]; 
 
for(int i=0; i<s; i++)
      nums[i] = input.nextInt();
      
System.out.println("Enter another sequence of positive integers");
 t = input.nextInt();
 int[ ] num2 = new int [t]; 
 
for(int j=0; j<t; j++)
      num2[j] = input.nextInt();
    

 
boolean same=Order.sameNumbers(nums, num2);
{
if (same==true){
System.out.println ("The sequences contain the same numbers.") ;
}
if (same==false){
System.out.println ("The sequences do NOT contain the same numbers."); 
}
}
}
public static boolean sameNumbers(int nums1[ ], int nums2[ ]) {
for (int i=0; i<nums1.length; i++) {
    for (int j=0; j<nums2.length; j++){
        if (nums1[i]==nums2[j])
        
        break;
    return true;
}
}
    return false; 
}
}
edit- last time I used a counter in the boolean method. shouldn't the break statement work just as well though? the way i understand it, if a number in nums2 matches up with a number in nums 1, then it will break and go back to the top. if the next number in nums2 matches up with a number in nums1, then it will break and go back to the top, etc. until it returns true. if a number ever does not match up, then it will skip down to return false.

this is how i did it last time:

Code:
 public static boolean sameNumbers(int nums[ ], int nums2 [ ])
    {
      
       int count = 0;
       
        for (int i = 0; i < nums.length; i++) {
            for(int j=0; j<nums2.length; j++) {

                if (nums[i] == nums2[j]) 

                count++;      
            
            }
        }
            
            if(count==nums.length)

            return true; 
            
            else 
            return false;       
            
}
}

Last edited by Go_Blue; 08-29-2012 at 06:01 PM.
Go_Blue is offline   Reply With Quote
Old 08-30-2012, 12:53 AM   #103
HypersionSD
centurion
 
Join Date: May 2012
Posts: 167
Re: Masters In Comp Sci With No Prior Experience

Do you know how to debug your code? What IDE are you using? If you can step though your running code using debug mode it will make your life 10 times easier.

"then it will break and go back to the top" I think you want to use continue.

Also since you are comparing int I don't think you need to use two for loops.
HypersionSD is offline   Reply With Quote
Old 08-30-2012, 12:00 PM   #104
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by HypersionSD View Post
Do you know how to debug your code? What IDE are you using? If you can step though your running code using debug mode it will make your life 10 times easier.

"then it will break and go back to the top" I think you want to use continue.

Also since you are comparing int I don't think you need to use two for loops.
You need two for loops because you are comparing two sequence of numbers. So, the user will input one sequence, which goes into Array 1 and then another sequence, which goes into Array 2. With the nested for loop, the first number in Array 2 will be checked against each number in Array 1, then the second number in Array 2 will be checked against each number in Array 1, then the third numer in Array 2 will be checked against each number in Array 1, etc.

I use Blue Jay for my compiler. Blue Jay tells you which line causes mistakes in a code. However, in this instance the program compiles...it just produces the wrong output. It will always produce the output "the sequences contain the same numbers," which means there is an issue with how I have my Boolean method set up.
Go_Blue is offline   Reply With Quote
Old 08-30-2012, 12:33 PM   #105
HypersionSD
centurion
 
Join Date: May 2012
Posts: 167
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
You need two for loops because you are comparing two sequence of numbers. So, the user will input one sequence, which goes into Array 1 and then another sequence, which goes into Array 2. With the nested for loop, the first number in Array 2 will be checked against each number in Array 1, then the second number in Array 2 will be checked against each number in Array 1, then the third numer in Array 2 will be checked against each number in Array 1, etc.

I use Blue Jay for my compiler. Blue Jay tells you which line causes mistakes in a code. However, in this instance the program compiles...it just produces the wrong output. It will always produce the output "the sequences contain the same numbers," which means there is an issue with how I have my Boolean method set up.
Let say I have the series of numbers 1,2,3 and 1,2,3. I could use a nested for loop or I could just concatenate the numbers and compare if(123 == 123).

You need to learn the difference between compile time errors and run time errors/bugs. Bluejay should allow you to step through the code at run time and see which lines of code are being executed in what order and what are the states of your objects/variables. I'm not an expert on bluejay but watch a video on bluejay and debugging.
HypersionSD is offline   Reply With Quote
Old 08-30-2012, 03:16 PM   #106
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

omfg this is awesome. i can't believe they didn't teach me how to do this in class. you can literally step line by line through the code.
Go_Blue is offline   Reply With Quote
Old 09-03-2012, 05:38 PM   #107
au4all
veteran
 
Join Date: Apr 2011
Posts: 2,822
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by HypersionSD View Post
Do you know how to debug your code? What IDE are you using? If you can step though your running code using debug mode it will make your life 10 times easier.

"then it will break and go back to the top" I think you want to use continue.

Also since you are comparing int I don't think you need to use two for loops.
You're exactly right. While a debugger would be helpful programmers needs to be able to step through this in their mind and/or a sheet of paper.

Start with two sequences of three items each.

Currently if both sequences are 222 I think the program would total 9.
au4all is offline   Reply With Quote
Old 09-03-2012, 05:57 PM   #108
au4all
veteran
 
Join Date: Apr 2011
Posts: 2,822
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
You need two for loops because you are comparing two sequence of numbers. So, the user will input one sequence, which goes into Array 1 and then another sequence, which goes into Array 2. With the nested for loop, the first number in Array 2 will be checked against each number in Array 1, then the second number in Array 2 will be checked against each number in Array 1, then the third numer in Array 2 will be checked against each number in Array 1, etc.

I use Blue Jay for my compiler. Blue Jay tells you which line causes mistakes in a code. However, in this instance the program compiles...it just produces the wrong output. It will always produce the output "the sequences contain the same numbers," which means there is an issue with how I have my Boolean method set up.
I'm mystified why you think that that tests whether the numbers are in sequence.

With that logic 123 and 321 are in sequence because each number is the first array is in the second.

If that's what your test shows then you have inadequate test data because if sequence one is 123 and sequence two is 456 the count should be zero
au4all is offline   Reply With Quote
Old 09-04-2012, 12:50 PM   #109
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

One of my best friends graduated from Cal Tech and is high up at a successful trading company. He's always been a really nice humble guy. But for whatever reason, whenever I bring up my programming progress or interests, he either changes the subject or gives very short answers. It's a completely new side to him that I'm trying to figure out.

It could also be similar to when I was a very good poker player and had friends come up to me all the time to share their thoughts on x,y,z concept. But, I can tell that he pretty much only has respect for people who got perfect grades at Stanford or came from the India Institute of Technology etc. He seems to view what I'm doing as a waste of time.

It's definitely frustrating, but I'm guessing that there are a lot of people out there like that and you just gotta have a thick skin and keep focusing on what you want to accomplish.
Go_Blue is offline   Reply With Quote
Old 09-04-2012, 02:56 PM   #110
Mariogs37
adept
 
Join Date: May 2012
Location: Formerly Mariogs379
Posts: 825
Re: Masters In Comp Sci With No Prior Experience

Meh, I would be surprised if he thought it was a waste of time tbh. I'm sure he was where you are now at some point. But yeah, not sure what to tell you re: him being curt / unresponsive about CS. Some people are just like that.

OTOH, I have a friend who's clearly much smarter than I am, currently at MSFT, and he has no problem helping me out when I text him with questions. Some people are more willing to help out others who know less; some aren't v. willing. F the haters imo.
Mariogs37 is offline   Reply With Quote
Old 09-04-2012, 03:16 PM   #111
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

So I plan to do a lot of outside learning in addition to my classes this semester.

I stumbled upon a really cool book called Code by Charles Petzold that I have been studying lately. Interestingly, my Discrete Math class made this book very easy to understand so far. A lot of it is about circuits which seem to use logic that I learned in that class. So far it has been really interesting and helps me understand the hardware aspect of things.

I also signed up for a class from this site: https://www.edx.org/dashboard
It is a SaaS class.

In addition to that, I started learning HTML; however, it's not nearly as interesting as the other things I've been learning. A lot of it is memorization/following the rules. I think maybe I'll give myself a project to make it more interesting.

The poster ClownTable mentioned a book a while back that I bookmarked involving Ruby on Rails, so I may pick that up.

Overall I need to be careful of taking on too much at once. However, there is so much cool stuff out there, and I left my job last week to give this 100% of my energy.
Go_Blue is offline   Reply With Quote
Old 09-04-2012, 04:04 PM   #112
alex23
veteran
 
Join Date: Feb 2008
Location: 1st world obv
Posts: 2,962
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
I also signed up for a class from this site: https://www.edx.org/dashboard
It is a SaaS class.
I took that class on coursera. It's a really interesting class, although pretty difficult if you have no background in the related topics (databases, basic networking, ruby/rails, testing, and backend web app engineering). If you don't have background in any of those, I'd recommend doing a bit of prep before it starts. Codeschool.com is pretty good and has quite a bit of related material. If you go through it before the class starts, you will likely find it a LOT easier (unless you already have background in those areas, in which case don't worry about it). For a free alternative prep course, this looks like it covers a decent amount of related topics and should also make it a bit easier http://www.udacity.com/overview/Cour...rseRev/apr2012, although in python rather than ruby/rails.
alex23 is offline   Reply With Quote
Old 09-04-2012, 04:08 PM   #113
alex23
veteran
 
Join Date: Feb 2008
Location: 1st world obv
Posts: 2,962
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
One of my best friends graduated from Cal Tech and is high up at a successful trading company. He's always been a really nice humble guy. But for whatever reason, whenever I bring up my programming progress or interests, he either changes the subject or gives very short answers. It's a completely new side to him that I'm trying to figure out.

It could also be similar to when I was a very good poker player and had friends come up to me all the time to share their thoughts on x,y,z concept. But, I can tell that he pretty much only has respect for people who got perfect grades at Stanford or came from the India Institute of Technology etc. He seems to view what I'm doing as a waste of time.

It's definitely frustrating, but I'm guessing that there are a lot of people out there like that and you just gotta have a thick skin and keep focusing on what you want to accomplish.
Could also be that he spends all his working hours worrying about this stuff, so he'd rather not think about it outside work.
alex23 is offline   Reply With Quote
Old 09-04-2012, 05:11 PM   #114
clowntable
Carpal \'Tunnel
 
clowntable's Avatar
 
Join Date: Jun 2006
Location: 39, 46, 56, 59, 191
Posts: 45,543
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
One of my best friends graduated from Cal Tech and is high up at a successful trading company. He's always been a really nice humble guy. But for whatever reason, whenever I bring up my programming progress or interests, he either changes the subject or gives very short answers. It's a completely new side to him that I'm trying to figure out.

It could also be similar to when I was a very good poker player and had friends come up to me all the time to share their thoughts on x,y,z concept. But, I can tell that he pretty much only has respect for people who got perfect grades at Stanford or came from the India Institute of Technology etc. He seems to view what I'm doing as a waste of time.

It's definitely frustrating, but I'm guessing that there are a lot of people out there like that and you just gotta have a thick skin and keep focusing on what you want to accomplish.
I'd actually say this is an uncommon attitude. Most programmers love to talk shop and help people.
Maybe he just deteriorated into pure elitism from being a trader :P

Quote:
Originally Posted by Go_Blue View Post
I stumbled upon a really cool book called Code by Charles Petzold that I have been studying lately. Interestingly, my Discrete Math class made this book very easy to understand so far.
Great book and there's even a programming thread about it in this form. I guess you'll really enjoy it.
https://forumserver.twoplustwo.com/19...chine-1222464/
clowntable is offline   Reply With Quote
Old 09-04-2012, 06:16 PM   #115
cyberfish
journeyman
 
Join Date: Sep 2004
Posts: 360
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
I stumbled upon a really cool book called Code by Charles Petzold that I have been studying lately.
Clowntable mentioned the thread which inspired myself too. I coded a binary adder in Java: https://github.com/L8Fish/Circuits
I think you (and Mariogs37) finished an introductory class in Java. And this is a great project to start if you're familiar with or learning about interfaces, inheritance, polymorphism, ... .
Keep in mind that my code is still messy and not documented well (a work in progress).

Fwiw I'm planning a career-switch too because I got passionate about programming.
cyberfish is offline   Reply With Quote
Old 09-05-2012, 08:49 PM   #116
au4all
veteran
 
Join Date: Apr 2011
Posts: 2,822
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
You need two for loops because you are comparing two sequence of numbers. So, the user will input one sequence, which goes into Array 1 and then another sequence, which goes into Array 2. With the nested for loop, the first number in Array 2 will be checked against each number in Array 1, then the second number in Array 2 will be checked against each number in Array 1, then the third numer in Array 2 will be checked against each number in Array 1, etc.

I use Blue Jay for my compiler. Blue Jay tells you which line causes mistakes in a code. However, in this instance the program compiles...it just produces the wrong output. It will always produce the output "the sequences contain the same numbers," which means there is an issue with how I have my Boolean method set up.
I still can't get over the fact that in deciding whether 12 and 21 are the same number (have the same digits in sequence) you think looking for a 1 in 21 somewhere followed by looking for a 2 in 21 somewhere is the correct process.

I especially wonder why after someone pointed out your obvious error that you disagreed with them.

One think about computer programming that you ought to know is that mistakes don't get hidden. When you create a web page with an error anyone who owns a web browser can see it. Given that you seem to believe the opposite I'm really curious why you posted the code to begin with.

Quote:
Originally Posted by Go_Blue View Post
One of my best friends graduated from Cal Tech and is high up at a successful trading company. He's always been a really nice humble guy. But for whatever reason, whenever I bring up my programming progress or interests, he either changes the subject or gives very short answers. It's a completely new side to him that I'm trying to figure out.

It could also be similar to when I was a very good poker player and had friends come up to me all the time to share their thoughts on x,y,z concept. But, I can tell that he pretty much only has respect for people who got perfect grades at Stanford or came from the India Institute of Technology etc. He seems to view what I'm doing as a waste of time.

It's definitely frustrating, but I'm guessing that there are a lot of people out there like that and you just gotta have a thick skin and keep focusing on what you want to accomplish.
You can either assume that his behavior has some strange purpose, or you could do the much more obvious thing and wonder why you're provoking that particular reaction.
au4all is offline   Reply With Quote
Old 09-05-2012, 10:01 PM   #117
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by au4all View Post
I still can't get over the fact that in deciding whether 12 and 21 are the same number (have the same digits in sequence) you think looking for a 1 in 21 somewhere followed by looking for a 2 in 21 somewhere is the correct process.

I especially wonder why after someone pointed out your obvious error that you disagreed with them.

One think about computer programming that you ought to know is that mistakes don't get hidden. When you create a web page with an error anyone who owns a web browser can see it. Given that you seem to believe the opposite I'm really curious why you posted the code to begin with.



You can either assume that his behavior has some strange purpose, or you could do the much more obvious thing and wonder why you're provoking that particular reaction.
I ignored your comment because of your hyperbolic way of talking. I believe you used the word "mystified," which I thought was funny.

In the problem posted by our professor, he misused the word "sequence." The program was just supposed to tell whether two sets of numbers were the same.

I disagreed with the above poster because I'm obviously learning. Writing out my way of thinking is helpful to continue learning. I'm not clear at all on why that bothers you.

The part you wrote about my friend makes no sense. I never assumed his behavior had a strange purpose; I was trying to figure out what would provoke that reaction. I've done a ton to help him in his life including with his trading strategies so I was hoping for more support from him as I go through this risky time period in my life. I'm not sure why I wrote that post about him--I guess it was on my mind.

Overall, you're one of these lunatic condescending posters that make posting on this site a lot less enjoyable.
Go_Blue is offline   Reply With Quote
Old 09-06-2012, 12:20 AM   #118
Mariogs37
adept
 
Join Date: May 2012
Location: Formerly Mariogs379
Posts: 825
Re: Masters In Comp Sci With No Prior Experience

Totally agree with Go_Blue here. Posters are here to learn; having someone who knows more bash them for asking questions makes forum a much less enjoyable place to learn.

I often ask math questions in SMP's HW Help Thread and PhD's help out all the time. My real analysis questions are really far beneath them, but you'd never know that based on the tone of their responses.

Basically, if you don't want to be constructive, just don't post.
Mariogs37 is offline   Reply With Quote
Old 09-06-2012, 08:54 AM   #119
cyberfish
journeyman
 
Join Date: Sep 2004
Posts: 360
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by Go_Blue View Post
I am working on an assignment from last semester as practice before classes start. I'm trying to do it in a different way than I did last time. Does anyone know why this isn't working? By isn't working I mean the output is incorrect.

The goal of the code is to say whether two sequences of numbers are identical.

CODE
I also interpret it in a different way. But assuming two sets have to be same:

Colors.sameNumber(int nums[ ], int nums2 [ ]):
nums={2,2,3} and nums2={2,3,2} returns false (fault).
nums={2,3} and nums2={5,2} returns true (fault).
You see why?

Quote:
Originally Posted by Go_Blue View Post
edit- last time I used a counter in the boolean method. shouldn't the break statement work just as well though? the way i understand it, if a number in nums2 matches up with a number in nums 1, then it will break and go back to the top. if the next number in nums2 matches up with a number in nums1, then it will break and go back to the top, etc. until it returns true. if a number ever does not match up, then it will skip down to return false.

this is how i did it last time:
CODE
Colors.sameNumber(int nums[ ], int nums2 [ ]):
nums={2,2,3} and nums2={3,2,2} returns false (fault).
nums={2,2,4,3} and nums2={5,6,2,2} returns true (fault).
You see why?

You've a correct implementation now? You have several possible solutions, including some fancy tricky ones:
You could multiply every digit in each array with a certain number (differs from digit to digit and should be chosen carefully), after adding the results together (seperate for both arrays) this gives two integers which need to be equal.
cyberfish is offline   Reply With Quote
Old 09-07-2012, 07:07 PM   #120
propstm
stranger
 
Join Date: Jul 2012
Location: Boston
Posts: 5
Re: Masters In Comp Sci With No Prior Experience

Hey Blue I've got a BS in Information Systems from GVSU and know a few people in the tech field in Chicago, how comfortable are you with the coding, I may be able to get in contact with them and inquire about internships.

Also as an aside, knowing how to program and problem solve is what is most important, knowing a particular language is just understanding syntax. Follow those concepts and Java will just be one of many languages you'll learn on this new path you've taken.
propstm is offline   Reply With Quote
Old 09-07-2012, 07:42 PM   #121
cyberfish
journeyman
 
Join Date: Sep 2004
Posts: 360
Re: Masters In Comp Sci With No Prior Experience

I made a mistake:

Quote:
Originally Posted by cyberfish View Post
Colors.sameNumber(int nums[ ], int nums2 [ ]):
nums={2,2,3} and nums2={2,3,2} returns false (fault).
nums={2,3} and nums2={5,2} returns true (fault).
You see why?
The bolded part will return true (correct).
-> nums={2,2,2} and nums2={2,2,2} returns false (fault).
cyberfish is offline   Reply With Quote
Old 09-10-2012, 09:36 PM   #122
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by propstm View Post
Hey Blue I've got a BS in Information Systems from GVSU and know a few people in the tech field in Chicago, how comfortable are you with the coding, I may be able to get in contact with them and inquire about internships.

Also as an aside, knowing how to program and problem solve is what is most important, knowing a particular language is just understanding syntax. Follow those concepts and Java will just be one of many languages you'll learn on this new path you've taken.
Thanks for the post. I am getting more comfortable with programming each day, but am still new to it. I would jump at the chance to intern somewhere.
Go_Blue is offline   Reply With Quote
Old 09-10-2012, 09:46 PM   #123
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

Quote:
Originally Posted by alex23 View Post
I took that class on coursera. It's a really interesting class, although pretty difficult if you have no background in the related topics (databases, basic networking, ruby/rails, testing, and backend web app engineering). If you don't have background in any of those, I'd recommend doing a bit of prep before it starts. Codeschool.com is pretty good and has quite a bit of related material. If you go through it before the class starts, you will likely find it a LOT easier (unless you already have background in those areas, in which case don't worry about it). For a free alternative prep course, this looks like it covers a decent amount of related topics and should also make it a bit easier http://www.udacity.com/overview/Cour...rseRev/apr2012, although in python rather than ruby/rails.
Cool, thanks for the heads up. I'll start looking through the material on CodeSchool.
Go_Blue is offline   Reply With Quote
Old 09-17-2012, 07:37 AM   #124
iamudit
stranger
 
Join Date: Sep 2012
Posts: 3
Re: Masters In Comp Sci With No Prior Experience

Your thread is a silver lining in the dark sky. I had given up the thought about MSCS as most of the universities told me I have very very little chance of getting admission for MS unless I go back and get another bachelors degree which is waste of time and money.
Your thread has inspired me. I have spent countless number of hours browsing through threads about MSCS without BSCS background. It took me an hour to read through the 9 pages but it was fun. It's like you're one quarter through climbing the Mt. Everest and 3 more quarters to go. I can feel your hunger.

I'm the same boat as you. I am currently pursuing my bachelors in commerce(last year) and interested in MSCS.
Since i'm from commerce background I have little or no knowledge about maths or any other subjects related to CS. My degree is about business management and marketing.

I have couple of questions regarding the pre-reqs exam you're taking.

How soon will you be done with all the subjects(fall to spring) before applying for MS?
Does DePaul have online classes for international students?
Should I follow your path to prepare myself for MS or some other path?

Any help will be greatly appreciated!

Regards,
Udit

Last edited by iamudit; 09-17-2012 at 07:44 AM.
iamudit is offline   Reply With Quote
Old 09-18-2012, 07:26 PM   #125
Go_Blue
centurion
 
Join Date: Jun 2012
Location: Chicago
Posts: 182
Re: Masters In Comp Sci With No Prior Experience

haha so this is sort of embarrassing but I spent hours working on my first C program where I was supposed to convert user input from hex to decimal. I decided to put the input into a char array and then wrote a function that reverses the array. Then I wrote a bunch of if statements with this general strategy
Code:
 if (s[i]>=0 || s[i]<=9)
                        hex+=pow(16,i)*s[i];
Anyway, there were a few errors that I couldn't figure out, so I went into Office Hours today and when my professor saw my program he was shocked. Apparently part of the functionality of "printf" is it does conversions for you. So I wrote a 60 line program when I really only needed 4 lines. I wrote the 4 line program earlier today in 5 minutes.

Super embarrassing...but I learned a lot about the C language struggling with my original program...so there's that.
Go_Blue is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 08:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © 2008-2010, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online