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);
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:
Anonymous2008-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:
Anonymous2008-10-20 21:44
Given this latest influx of clueless programming threads, I have the distinct suspicion that WHBT.
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.