Help

This is a discussion on Help within the C Programming forums, part of the General Programming Boards category; Hi, i was wondering if there is anyone out there kind enough to do the following code for me. i ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    54

    Help

    Hi, i was wondering if there is anyone out there kind enough to do the following code for me. i have no idea where to start since i dont know much about arrays.This is what the program should do:

    1) Prompt for and then accept 10 floating point values from the
    user.
    2) Store these values in an array.
    3) Pass the array to a procedure which prints out the values to
    4 decimal places in a numbered fashion (i.e like line numbers).
    4) Pass the array to a function which returns the maximum value.
    5) The returned maximum value is printed out in scientific or
    exponential format along with a suitable heading.


    Can someone please write the whole code???
    This is only a test code so its just so i get an idea, the main code is totally different
    Thanks

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    No-one here is going to do your homework for you but this should answer your first question:
    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Judging from your previous topics and your attitude of cheating and attempting to get homework done for free, I'm going to...:

    • ...call you a cheating dirtbag.
    • ...tell you to get help somewhere else.
    • ...tell you I hope you fail a course you don't deserve to pass.
    • ...point you towards my signature.
    • ...suggest that you learn the C language and how to apply it yourself, since we can't spoon-feed you throughout life.
    • ...tell you to actually write code and only ask for help when you actually need it and only under circumstances where it is permissable.


    OK. Try from there.

  4. #4
    Registered User
    Join Date
    Sep 2007
    Posts
    54
    In reply to MacGyver, if you dont want to help, you dont have to. you dont need to call me a dirtbag you can keep the comments for yourself.
    Anyway i have done a bit of a work on it and compiles and runs and it does wat it is suppose to, but it doesnt print out in a scientific manner i dont know how to do that...
    Here is the code so far:
    [code


    //This procedure takes the array and prints out
    /

    //1. "print 10 numbers"

    print_array(number);

    fprintf(output,"The MAXIMUM value of your entered numbers is %lf\n",min(number));

    }

    [/code]

    It also does not print out to 4 decimal places. i know i have to truncate but how???
    Last edited by juststartedC; 10-04-2007 at 02:08 PM.

  5. #5
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    I think this is how you print a float to 4dp using printf:
    Code:
    printf("%0.4f", num);

  6. #6
    Registered User
    Join Date
    Sep 2007
    Posts
    54
    oright dont worry about this thread my program works fine now
    Thanks anyway

  7. #7
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    Can someone please write the whole code???
    A question like this will get you a MacGyver-type response, especially given that's its not the first time you've been warned about things like this.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    > #1: Can someone please write the whole code???
    > #6: dont worry about this thread my program works fine now
    So you went from helpless to finished in under 4 hours?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    He wasn't calling you a dirtbag, he was projecting possible responses. Perhaps he should be a crystal ball engineer

    When they design courses they usually design them for the students not for the internet

    PS. This isn't a codefarm (How cunning of me, I made up a word deriving from renderfarm)
    Last edited by zacs7; 10-05-2007 at 12:00 AM.

  10. #10
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by zacs7 View Post
    He wasn't calling you a dirtbag, he was projecting possible responses.
    In this case, I was actually calling him that.

    Case in point, previous topic of his, he said this:

    Quote Originally Posted by juststartedC View Post
    Hi people.

    We are handing in our code as a university assignment. all the students get as much help as possible from each other and we even have some similar codes (please bare in mind that this is our first time writing a code) , however, the lecturer has mentioned that students are not allowed to copy each others work or even get help, he claims he has a very good software that checks and finds out if people cheated. i was wondering how the program works (i.e. if it looks at the name of the variables or the structure etc) and if it is possible to trick it (not that i have copied from anyone ) just out of curiosity.

    Any help would be greatly appreciated

    Thank you
    There is no doubt in my mind this moron cheats at his assignments given his begging for solutions. Salem pointed out how the guy all of a sudden managed to write a solution after asking us to do the entire thing for him. I don't think any of us really believe he's that good to sit down and figure it all out. I personally think he stole or borrowed the code from someone (or more likely a host of people from his class).

    It's a good thing I don't know his professor/teacher/instructor, but on the flip side, I would say that he will most likely fail the tests, since he is apparently unable to think and code on his feet if he needs to copy code in this manner. Even if he gets a degree, I doubt he'd last long in a real programming position.

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Hopefully, when he hands in two different assignments, written by two different people, his tutor will spot the sudden change in style and bounce his cheating ass out the door.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  12. #12
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > would say that he will most likely fail the tests, since he is apparently unable to think and code on his feet if he needs to copy code in this manner.
    Don't say that, he'll ask you to sit the test too.

    Hopefully his whoever will ask them to explain 'his' code, perhaps it's time to severely obfuscate homework answers or make them so inefficient it's ridiculous.

    The answer is actually,
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include <ctype.h>
    #include <stdlib.h>
    
    void main(void)
    {
        float * arr;
        char in[10];
        char i;
    
        memset(i, 0, 1);
    
        arr = malloc(pow(10,sizeof(float)));
    
        for(; i < 10; i++)
        {
            gets(in);
            sscanf(in, "&#37;f", &arr[i]);
        }
        
        
        return;
    }
    
    void printa(float * somethingReallyLongAndStuff)
    {
        char z;
        char i;
        
        memset(z, 0, 2);    /* lol */
    
        for(; z < 10; z++)
         printf("%f\n", somethingReallyLongAndStuff[z]);
    
        return;
    }
    etc in that fashion, theres a lot more rules you could break, and potentially predictable undefined behavior to exploit
    Last edited by zacs7; 10-06-2007 at 05:21 AM.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21