Turn on thread page Beta
    • Thread Starter
    Offline

    15
    ReputationRep:
    Attached is a C source code for my computing project due in on monday. do you think it is adequately readable (i.e. is it commented enough for a somewhat basic understanding for someone who doesn't know what it does?)
    Attached Files
  1. File Type: txt CO57.c.txt (6.7 KB, 241 views)
    Offline

    12
    ReputationRep:
    (Original post by elpaw)
    Attached is a C source code for my computing project due in on monday. do you think it is adequately readable (i.e. is it commented enough for a somewhat basic understanding for someone who doesn't know what it does?)
    You do programming in Physics? :confused:
    • Thread Starter
    Offline

    15
    ReputationRep:
    (Original post by bono)
    You do programming in Physics? :confused:
    yes, seeing as half of physics (the theoretical side) is mostly programming.
    Offline

    12
    ReputationRep:
    (Original post by elpaw)
    yes, seeing as half of physics (the theoretical side) is mostly programming.
    wow.
    Offline

    8
    ReputationRep:
    well I kinda understand it and I have next to no idea about programming...
    • Thread Starter
    Offline

    15
    ReputationRep:
    (Original post by piginapoke)
    Seems so to me. If in doubt, I'd put a pragraph or two in comments at the top explaining the whole process.
    i'm going to do that sort of stuff in the actual writeup
    Offline

    12
    ReputationRep:
    (Original post by elpaw)
    i'm going to do that sort of stuff in the actual writeup
    You are saying that half the course is programming?

    That can't be true, surely.
    • Thread Starter
    Offline

    15
    ReputationRep:
    (Original post by bono)
    You are saying that half the course is programming?

    That can't be true, surely.
    no, i was just saying that in real life, physics is (generally) split into theoretical and experimental physics, and the theoretical physicists use computing to model their theories

    the 1st year practical course is about 1/5 programming.
    Offline

    12
    ReputationRep:
    (Original post by elpaw)
    no, i was just saying that in real life, physics is (generally) split into theoretical and experimental physics, and the theoretical physicists use computing to model their theories

    the 1st year practical course is about 1/5 programming.
    Ahhh right.

    Although at uni I presume they do way more theoretical Physics, teaching Maths and Physical principles etc.?
    Offline

    10
    ReputationRep:
    (Original post by elpaw)
    yes, seeing as half of physics (the theoretical side) is mostly programming.
    Drool. Lucky you .

    Notepad didn't like your source, didn't put in the end lines as you would have. What did you write it in?
    Offline

    0
    ReputationRep:
    yeh, download, open in notepad....WTF!?? lol thats the process
    • Thread Starter
    Offline

    15
    ReputationRep:
    (Original post by Nylex)
    Drool. Lucky you .

    Notepad didn't like your source, didn't put in the end lines as you would have. What did you write it in?
    it was written on a solaris (unix) system. if you use wordpad, it displays it properly.

    edit: just for you i have edited it to add the "windows" line feeds... if you click on the attachment now it should work
    Offline

    10
    ReputationRep:
    I would so like to do programming like that as part of my course .

    It's definetly readable.. well commented . Btw, what does 'seed the random number generator' mean?? I've seen that before.
    • Thread Starter
    Offline

    15
    ReputationRep:
    (Original post by Nylex)
    It's definetly readable.. well commented . Btw, what does 'seed the random number generator' mean?? I've seen that before.
    the drand48() function generates a random number between 0 and 1. it's 'input' is the last random number that it generated. however, the first time that it is used, it always has the same input. so if you were to create a program that just printed out 10 random numbers, it would always print the same numbers every time it was run (that's not very random). so to seed it is to take a truly random number (the time, in my case) and that is the first 'input' to the RNG. so now, if it is seeded, every time it is run, the time is different, so the 10 random numbers it prints out will always be different.
    Offline

    10
    ReputationRep:
    (Original post by elpaw)
    the drand48() function generates a random number between 0 and 1. it's 'input' is the last random number that it generated. however, the first time that it is used, it always has the same input. so if you were to create a program that just printed out 10 random numbers, it would always print the same numbers every time it was run (that's not very random). so to seed it is to take a truly random number (the time, in my case) and that is the first 'input' to the RNG. so now, if it is seeded, every time it is run, the time is different, so the 10 random numbers it prints out will always be different.
    Ahh, nice one.
    • Thread Starter
    Offline

    15
    ReputationRep:
    (Original post by piginapoke)
    Is credit given for the code quality or just the readablity (as long as it performs its function correctly)?
    what do you mean by the code quality? there isn't really credit, there's just pass and fail (ie doing it and not doing it). i just want to make it look nice.
    Offline

    0
    ReputationRep:
    Your source code looked fine, I use the more cout method of doing it though but thats just the way I have been taught, the printf is older but perfectly valid for command line stuff.

    You have comment it well. Just one thing I have never come accross is the #include "gnuplot_i.c" library what is this?

    On the thing about physics most my programming lecturerss have physics PhD's. They have been teaching C in physics for the past 25 years now.
    • Thread Starter
    Offline

    15
    ReputationRep:
    (Original post by amazingtrade)
    Your source code looked fine, I use the more cout method of doing it though but thats just the way I have been taught, the printf is older but perfectly valid for command line stuff.

    You have comment it well. Just one thing I have never come accross is the #include "gnuplot_i.c" library what is this?

    On the thing about physics most my programming lecturerss have physics PhD's. They have been teaching C in physics for the past 25 years now.
    yeah, cout is in C++, printf is in C. we use C.

    as for gnuplot, its just a module that plots graphs and things like that.
    • Thread Starter
    Offline

    15
    ReputationRep:
    for anyone still interested, here is my final version.

    cheers to piginapoke about the declaring variables in loops, i just wanted an easy method of reseting the arrays, ie instead of
    Code:
    for(i=0;i<5;i++){
      array[i] = 0;
    }
    have
    Code:
    int array [5] = {0,0,0,0,0};
    but that only works when declaring a variable.
    Attached Files
  2. File Type: txt CO57.c.txt (8.7 KB, 116 views)
 
 
 

University open days

  • University of Roehampton
    All departments Undergraduate
    Sat, 17 Nov '18
  • Edge Hill University
    Faculty of Health and Social Care Undergraduate
    Sat, 17 Nov '18
  • Bournemouth University
    Undergraduate Open Day Undergraduate
    Sat, 17 Nov '18
Poll
Black Friday: Yay or Nay?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.