Only logged in members can reply and interact with the post.
Join SimilarWorlds for FREE »

It's updated for today's commit.


The code is getting better and better

lines (18 sloc) 538 Bytes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "float-input.h"

int main() {
float fahr, celsius;

puts("Enter temperature in Fahrenheit: ");

while (isnan(fahr) || isinf(fahr)) {
fprintf(stderr, "[ERROR]: Invalid input: please enter a valid temperature.\n");
puts("Enter temperature in Fahrenheit: ");

celsius = (fahr- 32) * 5 / 9;

printf("%3.0f %6.10f\n", fahr, celsius);

return 0;

cl.exe /nologo /Ox /MT /W0 /GS- /DNDEBUG /I "path to the .h file" faherheit_to_celsius.c /link /OUT:faherheit_to_celsius.exe /SUBSYSTEM:CONSOLE /MACHINE:x64
Author unknown:

When I find my code in tons of trouble
Friends and colleagues come to me
Speaking words of wisdom
Write in C

As the deadline fast approaches
And bugs are all I can see
Somewhere someone whispers
Write in C

Write in C
Write in C
Write in C
Write in C
LISP is dead and buried
Write in C

I used to write a lot of FORTRAN
For science it worked flawlessly
Try using it for graphics
Write in C

If you just spent nearly 30 hours
Debugging some assembly
Soon you'll be glad to
Write in C

Write in C
Write in C
Write in C, yeah
Write in C

Only wimps use BASIC
Write in C

Ever more at https://genius.com/Unattributed-write-in-c-lyrics
DeWayfarer · 61-69, M
@ElwoodBlues true about the time. True about the bloat though. You are trading one for the other.

There simply is far too much bloat in today's code. We are quickly approaching the heat limits when it comes to todays computers.

Time to eliminate the bloat.
@DeWayfarer Data point: this guy wrote X86 code for a matrix determinant in both C++ and ASM. In his case, the C++ was faster by about 6%.

DeWayfarer · 61-69, M
@ElwoodBlues that is dependent on the programmers techniques. I think you know that.
C is seems cumbersome
@Ozymandiaz Yes. Python's interepter was written in c. it's good at a lot of things. C would still be faster at doing all of those things.
@Ozymandiaz I had a CS teacher who used to say that you only start to understand what programming is when you're on your 2nd or 3rd language.

I'm a might big fan of Python; I think the ideal these days is write some UI and maybe control logic in Python, but do the numerical stuff in C so you can take advantage of the speed & size benefits.
@Ozymandiaz python is supposed to make developers happy but what makes me happy is code that executes quickly. and while c is "cumbersome" in the kind of way like having to declare your variables and everytihng thats what makes it perform well.

I like python but that isn't going to change the fact that a lower level language can do what python can do and quicker. C isn't assembly sure but it's a hell of a lot faster at developing than assembly. you think c is bad you should look at assembly.

I started learning C because the last thing I want to be is a soydev, who doesn't give a fuck if it performs well because computers will get faster in the future.

Post Comment