Remove ads, unlock a dark mode theme, and get other perks by upgrading your account. Experience the website the way it's meant to be.

Programming • Page 3

Discussion in 'Technology Forum' started by Dirty Sanchez, Mar 5, 2016.

  1. noxee

    Regular Prestigious

    isPrime could be written with either a for or a while loop.

    bool isPrime(int num) {  
      for (int i = num - 1; i > 2; i--){
        if (num % i == 0) return false;
      }
      return true;
    }
    
    or
    bool isPrime(int num) {
      if (num < 2) return false;
    
      bool prime = true;
      int factor = num - 1;
    
      while (prime && factor > 1) {
        if (num % factor == 0) prime = false;
        else --factor;
      }
    
      return prime;
    }
    

    Were you required to write the find findFibo as a recursive function?
     
    Jason Tate, DeviantRogue and stnewton like this.
  2. DeviantRogue

    Take arms, it'll all blow over Prestigious

    Yeah managed to get the findFibo to work.

    Didn't have time to finish the last function
     
  3. Timmiluvs

    I play video games fast Prestigious

    Couldn't think of a better thread to post this in, so this will do.

    This laptop looks really interesting with me given it's in depth security with it's BIOS and other things. Plus the OS looks really minimalist and unique compared to other Linux based ones. I'll probably pick on up soon since I don't have a good coding laptop handy right now.
     
  4. I should probably style that code bbcode block a little better.
     
  5. noxee

    Regular Prestigious

    Does BBCode support code syntax highlighting? Or could you plug in something like highlight.js ?
     
  6. Malatesta

    i may get better but we won't ever get well Prestigious

    i studied programming in high school and early on in college - it works pretty naturally with my strengths and i have a strong understanding of the basics (for loops, while loops, booleans, general syntax and processing rules, etc, as well as surface level to moderate understanding of a handful of languages that presumably now have mostly faded from memory) but I haven't had time to keep up with it. i will have some more free time starting in a few weeks as i'll be on co-op. what's a good language to get back into the flow of things with?
     
  7. Timmiluvs

    I play video games fast Prestigious

    Java is always a good starting point. Python is too. I feel like you can pick up both of them pretty easily since you have background in the basic concepts as well.
     
  8. Malatesta

    i may get better but we won't ever get well Prestigious

    yep, i've studied both of those, Python a little more in-depth than Java though. maybe I will go that way, I'm mostly trying to think about what will make me most appealing as a job candidate (so I might also brush up my Matlab skills) and those are pretty ubiquitously useful
     
  9. Timmiluvs

    I play video games fast Prestigious

    I tried looking at Matlab once and hated it haha. Probably just cause I've never actually sat down and studied it.

    The next language I'm going to sit down and learn a lot of is Golang. Functional languages have always interested me and Golang has been talked about a ton recently so I'm curious to take a look at it.
     
  10. Malatesta

    i may get better but we won't ever get well Prestigious

    yeah it definitely is not gonna appeal to everyone - its strengths are in data analysis and math operations as far as i understand so biomedical engineers (which is what i'm studying) in particular are encouraged to learn it so we can analyze our own data rather than having to push it to a different team member.
     
  11. Timmiluvs

    I play video games fast Prestigious

    Makes sense, I know a lot of bio and chem engineers who use it. And it's good for that kind of analysis and processing, so I'm not surprised it has good use for those fields.
     
  12. Dirty Sanchez

    Prestigious Prestigious

    I had to use matlab today in a lab about image processing. :redanger: and by today, I mean every Friday. :redanger::redanger:
     
  13. It doesn't that I could see. I looked at highlight.js, but decided not to include another library at this point.

    I did clean up the [code] style though to not look so funky and be a kinda cool different thing.
     
  14. Nick

    @fangclubb Prestigious

    Matlab is the worst. But I did do image processing in my final year and it was an easy class.
     
  15. Nick

    @fangclubb Prestigious

    Used bootstrap for the first time tonight while messing around with jquery. It's a lovely little thing.
     
    Jason Tate and Dirty Sanchez like this.
  16. danielalee12

    Regular

    Bootstrap is super fun to mess around with, with the added benefit of looking great too.
     
  17. Brenden

    Trusted Prestigious

    Do all you guys use programming for your jobs or plan on going in a career with it? Or is it just a hobby?

    Its a skill I wish I learned but growing up I was to much of a meathead to ever consider it.
     
  18. Malatesta

    i may get better but we won't ever get well Prestigious

    hobby + job, I don't want to program all the time but I'll need it for data analysis in at least some form.

    it's never too late to start! while I think being exceptionally good at coding is not something everyone can achieve, I do think everyone can and should learn in some capacity how to think in coding and build some skill in the subject. there are plenty of great, free places to start, like Codeacademy, Khan Academy, codecamp, and codeconquest.
     
    Jason Tate and Dirty Sanchez like this.
  19. Dirty Sanchez

    Prestigious Prestigious

    When I graduate, I plan to do nothing but code.
     
  20. Nick

    @fangclubb Prestigious

    I did programming for my undergrad but got a business job. Trying to move back to a programming job.
     
  21. matthaber

    beautiful and chequered, the end

    Ohhhh a programming thread. I should spend more time here.

    It's weird, I did/still doing my undergrad for computer science with the intention of being a developer, but ended up falling into a position as a junior dev-ops position, which has quickly turned into me being promoted and becoming the only dev-ops at my company.I get to write some basic scripts in python from time to time but for the most part I spend the majority of my days working on server infrastructure (a lot of salt stack), I'm learning a ton of new stuff (which for the most part is all very interesting) but i really do miss spending my time developing. I really want to pick up a personal project to keep my programming skills up to practice, but I find it soooo hard to spend my time coding after working a full day of doing dev-ops stuff. Heck, Id love to start developing a video game idea I have, but thats an even bigger time commitment that just practicing my programming skills.
     
    Jason Tate likes this.
  22. DeviantRogue

    Take arms, it'll all blow over Prestigious

    So we are doing arrays and I've missed the last two classes due to being sick, have this program due tomorrow at 10pm, (my program is a complete mess and isn't working at all), if any of you guys mind taking a look, and letting me know how to fix this, pm me! I'd be eternally grateful.
     
  23. Feel free to just post here, but you can also PM me if you'd like.
     
  24. Nick

    @fangclubb Prestigious

    I had a look at it earlier and think I nudged him in the right direction, but I haven't been able to properly compile it and see. @scott you're probably in a better position to help till I finish work.
     
  25. DeviantRogue

    Take arms, it'll all blow over Prestigious

    Here's the original code for posterity. Got classes until 6pm today, so I won't be able to actually edit/run it till then.

    #include <iostream>
    #include <fstream>
    #include <cmath>
    
    using namespace std;
    
    void getData(string fileName, double temperature[], int &nDays)
    {
        ifstream inFile;
            inFile.open(fileName.c_str());
    
            nDays = 0;
            temperature;
    
    
            while (inFile >> temperature)
            {
                cout << temperature << " and June " << nDays << endl;
                temperature[nDays] = temperature;
                nDays++;
            }
    
        cout <<"in getData ... numDays is " << nDays << endl;
    }
    
    double findHighestTemp(double temperature[], int numDays, int highest)
    {
    
        for (int i = 1; i > numDays; i++)
        {
    
            if (temperature[i] < temperature[higest])
            int higest = i;
        }
    
        return highest;
    
    }
    
    int showDaysOver100(double temperature[], int numDays, int tempOver100)
    {
        for (int i = 0; i < numDays; i++)
        {
            if (temperature[i] => tempOver100)
            {
                int dayOver100 = 0;
                dayover100++;
            }
    
    
        }
    }
    
    double averageTemp(double temperature[], int numDays)
    {
        for (i = 0; i < numdays; i++)
        {
            totalTemps = 0;
    
            totaltemps += temperature[i];
        }
    
        double average = totalTemps / numDays;
    
        return average;
    }
    
    int main()
    {
        const int MAX_DAYS = 30;
        double temperature[MAX_DAYS];
        const string fileName = "summer_temps.txt";
        int numDays = 0;
    
    
    
        getData(fileName, temperature, numDays);
    
    cout << "number of days is " << numDays << endl;
    
    
        for (int i = 0; i < numDays; i++)
        {
            cout << "June " << i << " - " << temperature[i] << endl;
        }
    
        double maxTemp = findHighestTemp(temperature, numDays);
    
        cout << "Maximum temperature: " << temperature[highest] << " (occurred on June " << highest << ")" << endl;
    
        int tempOver100 = 100;
        int numDaysOver100 = showDaysOver100(temperature, numDays, tempOver100);
        cout << "Number of days over 100 : " << dayover100 << endl;
    
        double averageTemp(double temperature[], numDays)
        cout << "Average daily high temperature: " << average << endl;
    
        return 0;
    }
    
    [code]