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

Pages: 1-

C programming help

Name: op 2011-11-05 15:22

Hey guys a avid python lover here. I'm reading K and R and I'm wondering why the fuck does this not work? thanks for any help

#include <stdio.h>

main()
{
    float k, c, f;
    int step, low;
    f = 0;
    step = 10;
    while (f <= 1000)
    {
        c = ((f - 32) / 1.8);
        k = (c + 273.15);
        printf("%d degrees farhienheit is equal to %d degrees celcius and %d degrees kelvin\n", f, c, k);
        f += step;
    }
    getchar();
}

Name: Anonymous 2011-11-05 15:25

because it's not python

Name: Anonymous 2011-11-05 15:28

getchar();
ISHYGDDT

Name: Anonymous 2011-11-05 15:29

>>3
Fixed:

#include <stdio.h>

main()
{
    float k, c, f;
    int step, low;
    f = 0;
    step = 10;
    while (f <= 1000)
    {
        c = ((f - 32) / 1.8);
        k = (c + 273.15);
        printf("%d degrees farhienheit is equal to %d degrees celcius and %d degrees kelvin\n", f, c, k);
        f += step;
    }
    system("PAUSE");
}

Name: Anonymous 2011-11-05 15:33

What isn't working?

Name: Anonymous 2011-11-05 16:00

the vaule of f isn't increading

Name: Anonymous 2011-11-05 16:28

the value of f isn't increasing anyone know why?

Name: Anonymous 2011-11-05 16:52

mfw when noone on prog can code -_-

Name: Anonymous 2011-11-05 17:08

>>7
#include <stdio.h>

int main(void)
{
    double k, c, f;
    int step;
    f = 0;
    step = 10;

    while (f <= 1000)
    {
        c = (f - 32) / 1.8;
        k = c + 273.15;
        printf("%g degrees farhienheit is equal to %g degrees celcius and %g degrees kelvin\n", f, c, k);
        f += step;
    }

    getchar();

    return 0;
}

Name: VIPPER 2011-11-05 17:12

>>8
May THE JEWISH ANAL RAPE OF DOOM last a trillion melenia fo you.

Name: Anonymous 2011-11-05 17:14

>>8
/prog/ is about getting duubzz!

Name: Anonymous 2011-11-05 17:24

>>8
I can!
trolling is just so much more fun!

Name: Anonymous 2011-11-05 18:17

holy shit thanks /prog/

Name: Anonymous 2011-11-05 18:34

>>13
I am not /prog/, I am from /g/.

Name: Anonymous 2011-11-05 20:15

(define (main f step)
  (if (<= f 1000)
    (let ((c (/ (- f 32) 1.8)))
      (display f)
      (display " degrees farhienheit is equal to ")
      (display c)
      (display " degrees celcius and ")
      (display (+ c 273.15))
      (display " degrees kelvin")
      (newline)
      (main (+ f step) step))))

(main 0 20)

Name: Anonymous 2011-11-05 20:29

>>15
Perl: say("hell")
Lisp: (display "hell") (newline)
that is why Lisp unpopular

Name: Anonymous 2011-11-05 20:59

Sperm A style formatting is terser
(printf "~a degrees farhienheit is equal to ~a degrees celcius and ~a degrees kelvin~n"
        f c (+ c 273.15))

Name: Anonymous 2011-11-05 21:10

>>16
(define (say something) (display something) (newline))
(say "hello")


That's was so difficult, I bet none of the Lisp programmers ever thought of it.

Name: Anonymous 2011-11-05 21:19

>>17
(printf
What happened to format?

Name: Anonymous 2011-11-05 21:21

>>19
Lispers finally agreed that C/C++ functions are superior. Just wait till they implement public-void-static-class-faggotry

Name: Anonymous 2011-11-05 21:24

>>17
print("$f degrees farhienheit is equal to $c degrees celcius and $(+ c 273.15) degrees kelvin~n")
even PHP owns Lisp.

Name: Anonymous 2011-11-05 21:34

>>19
Not sure about the other Schemes but in Racket format returns a formatted string instead of printing to (current-output-port).

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