1. DLP Flash Christmas Competition + Writing Marathon 2024!

    Competition topic: Magical New Year!

    Marathon goal? Crank out words!

    Check the marathon thread or competition thread for details.

    Dismiss Notice
  2. Hi there, Guest

    Only registered users can really experience what DLP has to offer. Many forums are only accessible if you have an account. Why don't you register?
    Dismiss Notice
  3. Introducing for your Perusing Pleasure

    New Thread Thursday
    +
    Shit Post Sunday

    READ ME
    Dismiss Notice

Programming !! :D

Discussion in 'Tech Support' started by Skykes, Dec 7, 2010.

  1. Skykes

    Skykes Minister of Magic DLP Supporter

    Joined:
    May 14, 2006
    Messages:
    1,353
    Location:
    Ireland
    Hey all,

    So I have my programming assignment due in a few days(monday the 13th). I don't have a clue how to do it. So I was wondering if anybody knows some good tutorial websites online ? Most of what I have seen is for C++ or C#


    For those interested:
    Design, write and to input numbers and manipulate 2 5x5 matrices.
    The program must then present the user with the following options:

    1. Input the data into matrix 1
    2. Input the data into matrix 2
    3. Display the matrices in a horizontal
    4. Determine the % sparsity of each matrix
    5. Add the matrices and display the result
    6. Multiply the matrices and display the result
    7. End Program
     
    Last edited: Dec 7, 2010
  2. Heleor

    Heleor EsperJones DLP Supporter

    Joined:
    Mar 3, 2006
    Messages:
    1,431
    Location:
    Seattle, WA
    Er, if you have no idea how to do this, what the hell were you doing in class all that time? I'd understand if this was for you personally wanting to learn, but you're obviously in a class.
     
  3. Oz

    Oz For Zombie. Moderator DLP Supporter

    Joined:
    Jan 31, 2008
    Messages:
    9,028
    Gender:
    Female
    Location:
    Baile Átha Cliath
    What language?

    EDIT:
    Code:
    public class SistersArm{
       public static void main(String[] args){
          grab.herArm();
          break;
       }
    }
    lulz
     
    Last edited: Dec 7, 2010
  4. Seratin

    Seratin Proudmander –§ Prestigious §– DLP Supporter

    Joined:
    Oct 14, 2007
    Messages:
    293
    Location:
    Dún na ngall
    High Score:
    5,792
    Some good programming thar.
     
  5. silverlasso

    silverlasso Minister of Magic DLP Supporter

    Joined:
    Dec 7, 2007
    Messages:
    1,302
    Location:
    San Francisco
    What language is this supposed to be in?

    In any case, the overall structure should be something like:

    Code:
    main:
         loop that runs until user enters option 8:
              display options, capture user entry
              depending on the option, run the the corresponding separate method/function/(quit the program if user entered 8)
    
    separate methods/functions
    
    Eh, it's hard to come up with a structure without actually writing the program itself.

    Can you give more details about the assignment and your current programming knowledge?
     
  6. Skykes

    Skykes Minister of Magic DLP Supporter

    Joined:
    May 14, 2006
    Messages:
    1,353
    Location:
    Ireland
    I have very little knowledge, I can do basic nested for/while loops. Thanks for the replies.

    I'm going to go to bed now, can't even look at another line of code tonight.

    Edit:

    Just noticed Seratin's post:
    Irish are known for women beating :/ How can I possibly beat a stereotype!
     
    Last edited: Dec 7, 2010
  7. Perspicacity

    Perspicacity Destroyer of Worlds ~ Prestige ~ DLP Supporter

    Joined:
    Nov 27, 2007
    Messages:
    1,022
    Location:
    Where idiots are not legally permitted to vote
    High Score:
    3,994
    I am so tempted to answer with an obfuscatory-C-style solution. Instead, I suggest you ditch C/C++, which are stodgy and plebeian nowadays, and adopt the one true programming language: Brainfuck.
     
  8. Heleor

    Heleor EsperJones DLP Supporter

    Joined:
    Mar 3, 2006
    Messages:
    1,431
    Location:
    Seattle, WA
  9. Nukular Winter

    Nukular Winter The Chosen One DLP Supporter

    Joined:
    Jun 8, 2006
    Messages:
    2,216
    Location:
    Seattle
    Are you having trouble with the matrix math or the actual programming? If the latter, have you considered going to your professor's office hours for help?

    If you want to post your code I'd be happy to critique it, but I'm not going to do your homework for you.
     
  10. fuubar

    fuubar Headmaster

    Joined:
    Nov 17, 2007
    Messages:
    1,101
    Such an awesome language.

    But you need to have him learn something useful!

    Also, OP, those of us who do know how won't do your homework, post code and ask specific questions and I'm sure we'd be more than happy to point you in the right direction.

    Some sites you might look at:

    http://www.cplusplus.com/
    http://stackoverflow.com/
    http://download.oracle.com/javase/tutorial/

    If you specify what language your using I could probably be a little bit more specific.
     
  11. KrzaQ

    KrzaQ Denarii Host DLP Supporter

    Joined:
    May 9, 2008
    Messages:
    1,404
    Location:
    Poland
    What's the difference between option 5 and 6?
     
  12. silverlasso

    silverlasso Minister of Magic DLP Supporter

    Joined:
    Dec 7, 2007
    Messages:
    1,302
    Location:
    San Francisco
    fuubar: The assignment is apparently supposed to be in C.

    Skykes:I was bored so I wrote a version of the program. It's not too difficult, but if you don't know much I can understand that it might take you a while. Try and get some code written and maybe we can give you some actual *pointers.

    Edit:

    KrzaQ: Maybe one of them is supposed be subtraction.
     
  13. Skykes

    Skykes Minister of Magic DLP Supporter

    Joined:
    May 14, 2006
    Messages:
    1,353
    Location:
    Ireland
    I know C is old but that's what we have to do.
    One of them shouldn't be there, I typed it late.
    I understand the maths just fine.. well almost, adding and multiplying is okish. I'm not really sure what the %sparsity means.

    edit2:
    Realised that I forgot a ;

    Am I going to need to declare 50 integers? (25 for each matrix).
     
    Last edited: Dec 7, 2010
  14. Perspicacity

    Perspicacity Destroyer of Worlds ~ Prestige ~ DLP Supporter

    Joined:
    Nov 27, 2007
    Messages:
    1,022
    Location:
    Where idiots are not legally permitted to vote
    High Score:
    3,994
    "Sparsity" and "density" pertaining to matrices relate to how many elements of a matrix are zero compared with the total number of elements in the matrix.

    If you really want help, do as NW mentioned and post your code so folks can give you hints. We won't do your homework for you.
     
  15. Oz

    Oz For Zombie. Moderator DLP Supporter

    Joined:
    Jan 31, 2008
    Messages:
    9,028
    Gender:
    Female
    Location:
    Baile Átha Cliath
    Well for starters, your code isn't even nearly complete. Every opening brace should have a corresponding closing brace.
     
  16. Perspicacity

    Perspicacity Destroyer of Worlds ~ Prestige ~ DLP Supporter

    Joined:
    Nov 27, 2007
    Messages:
    1,022
    Location:
    Where idiots are not legally permitted to vote
    High Score:
    3,994
    Some basic C questions relevant to a part of your assignment have been covered in another thread, including an utterly over the top code snippet by someone on sanitized user textual data input into a code.
     
  17. Skykes

    Skykes Minister of Magic DLP Supporter

    Joined:
    May 14, 2006
    Messages:
    1,353
    Location:
    Ireland
    Thanks for the reply. I'm not really sure where to go from here. Do I use an IF loop?

    Code:
     #include <stdio.h>
    #include <conio.h>
    
    void main() 
    
    { 
        /*matrix 1*/
        int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y;
        /*matrix 2*/
        int a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1, q1, r1, s1, t1, u1, v1, w1, x1, y1;
        
      
    printf("1. Input the data into matrix 1\n 2. Input the data into matrix2\n 3. Display the matrices in a horizontal\n 4. Determine the %spasity of each matrix\n";
    printf("5. Add the matrices and display the result\n 6. Multiply the matrices and dispaly the result 7. End program"); 
        
        printf("Please enter the data for matrix 1");
        scanf("%d" &a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y);
        printf("Please enter the data for matrix 2");
        scanf("%d" %a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1, q1, r1, s1, t1, u1, v1, w1, x1, y1);
    
     
  18. Johnny Farrar

    Johnny Farrar High Inquisitor

    Joined:
    Mar 14, 2009
    Messages:
    521
    Location:
    In front of a Computer.
    There is always a closing brace to an opening brace, Always. Good programming convention says to close the brace immediately after you open it before adding the statements in the middle. That way you don't forget the closing braces which can get very confusing in nested loops.

    Other than that, how familiar are you with the C language. Because if you don't even know how to use the printf and scanf functions properly you're going to do find it difficult to do the assignment properly.
     
  19. Skykes

    Skykes Minister of Magic DLP Supporter

    Joined:
    May 14, 2006
    Messages:
    1,353
    Location:
    Ireland
    I am not very good at C(to state the obvious). Family problems caused me to miss a lot of class over the last 2 months.

    What is wrong with my printf and scanf ?
    I am trying to use an IF loop and have the user enter a number, putting that value to an variable. So if the variable is given the value of 1 then it will do the first part. I am having trouble with the nested loop.
     
  20. Perspicacity

    Perspicacity Destroyer of Worlds ~ Prestige ~ DLP Supporter

    Joined:
    Nov 27, 2007
    Messages:
    1,022
    Location:
    Where idiots are not legally permitted to vote
    High Score:
    3,994
    You also should look up how to use arrays. You can loop over entries in an array a lot easier than you can a gazillion variables. For example:

    Code:
    #include <stdio.h>
    
    #define ARRLEN 3
    int main( int argc, char *argv[] ) {
      int a[ARRLEN] = { 0, 1, 2 };
      int i;
    
      for ( i=0; i<ARRLEN; ++i ) {
        printf( "element %d = %d\n", i, a[i] );  
      }
    
      return 0;
    }
    
    Play with this snippet and figure out what each bit does. When you understand, the rest of your assignment should be pretty simple.

    You should give serious thought to either knuckling down and spending the time to learn what you've missed (as opposed to look to DLP for shortcuts, which won't help you in the end) or dropping the class.

    Edit: An Easter Egg to slightly less novice coders who may be reading: try the above, though with a replaced by i[a]. Then figure out why you get what you do.

    It's because the compiler parses a as *(a+i). Since addition of a pointer-to-int to an int promotes to type pointer-to-int, i+a and a+i give the same memory address.
     
    Last edited: Dec 7, 2010
Loading...