Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

i need help ><

Name: Anonymous 2008-10-20 19:18

hey guys, im really new to programming and my homework tonight is to make a program that asks for 2 numbers then adds, subtracts, multiplies and divides them.  my subtraction formula is not working and im really frustrated ><  could you guys help?  also when i do something like... printf("%2.4f");     its not working for me and i dont know why, im using code blocks.  ill post my work below here, thanks!  (remember i suck at programming and im new, and im not done yet.... this is in C!!! not c++)

#include <stdio.h>

int main(void)
{
    float num1, num2, add, subtract, multiply, divide;

    printf("This program will ask you for two numbers.");

    printf("Please enter a number:");
    scanf("%f", &num1);

    printf("Please type in another number:");
    scanf("%f", &num2);

    add = num1 + num2;

    printf("%f", num1);
    printf(" Added to ");
    printf("%f", num2);
    printf("Equals ");
    printf("%f", add);

    num1 - num2 = subtract
   
    printf("%f", num1);
    printf(" Minus ");
    printf("%f", num2);
    printf("Equals ");
    printf("%f", subtract);

    return (0);
}

Name: Anonymous 2008-10-20 19:26

Holy god.

Name: Anonymous 2008-10-20 19:39

shit i figured it out, nvm sorry guys xD  fucking small stupid mistake

Name: Anonymous 2008-10-20 19:58

haha

Name: Anonymous 2008-10-20 20:20

C is not like Prolog; = is not commutative
No newlines in printf and related buffering problems
No skipping of whitespace in scanf
No error checking on scanf
Uncoalesced printf's
Useless variables
Returns are usually written without the parentheses
return 0 may be omitted from main in C99

Also:
Input should be possible from the command line arguments
Only the first word in a sentence should be capitalized

Name: Anonymous 2008-10-20 20:27

dont know much of what you just said cus im really new to programming (1 month), but i spaced stuff out so i can read it easlyer cus when i dont do the useless spaces its all crowded and stuff.  i got the programm up and running perfectly :)  thanks so much for the reply

Name: Anonymous 2008-10-20 21:44

Given this latest influx of clueless programming threads, I have the distinct suspicion that WHBT.

Name: Anonymous 2008-10-20 21:55

Take this shit to /g/. I'm sorry, but you'll never meet /prog/'s high standards for trolls, meta trolls, meta meta trolls, etc. Don't be sad, our economy requires people like you as well, filling the trolling equivalent of a burger-flipping job.

Name: Anonymous 2008-10-20 22:17

Forget it, it's P.

Name: ShotgunNinja 2008-10-20 23:21

God damn. I can write a streaming video server protocol in my spare time, and I'm 16 and work at Burger King.


DON'T use us burger-flippers as a stereotype.

Name: Anonymous 2008-10-20 23:24

>>10
LMAO. I work from my basement. Fuqin loser.

Name: Anonymous 2008-10-21 0:24

>>10
Back to the fryer, Ginger

Name: Anonymous 2008-10-21 0:29

>>12
I'd lick the Ginger's irish potatoes, if you catch my drift.

Name: Anonymous 2008-10-21 9:53

>>13
I'd mash up The Ginger's Irish potatoes and make a tasty potato hash, if you catch my drift.

Name: Anonymous 2008-10-21 10:28

I'd sprinkle some ginger on the Ginger's cock and then eat it.

Name: Anonymous 2008-10-21 10:52

>>10
underage b&

Name: Anonymous 2008-10-21 12:39

why do britfags call people with bright reddish orange hair ginger? ginger is not even anywhere close to that color...
http://www.global-b2b-network.com/direct/dbimage/50353349/Ginger.jpg

Name: Anonymous 2008-10-21 16:07

>>17
The pale skin of ginger's innards, which gingers typically have

Name: Anonymous 2008-10-21 19:01

#include <stdio.h>

int main() {
    float num1, num2, add, subtract, multiply, divide;
    printf("This program will ask you for two numbers. Please enter a number: ");
    scanf("%f", &num1);
    printf("\nPlease type in another number:");
    scanf("%f", &num2);
    add = num1 + num2;
    printf("\n%f added to %f equals %f", num1, num2, add);
    subtract = num1 - num2;
    printf("\n%f subtracted by %f equals %f", num1, num2, substract);
    multiply = num1 * num2;
    printf("\n%f multiplied by %f equals %f", num1, num2, multiply);
    divide = num1 / num2;
    printf("\n%f divided by %f equals %f", num1, num2, divide);
//time to die.
    return 0;
}

Name: Anonymous 2010-12-17 1:26

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-01-31 20:01

<-- check em dubz

Name: Anonymous 2011-02-03 6:55


Don't change these.
Name: Email:
Entire Thread Thread List