• 0

    posted a message on So I wanted to learn C...
    Now to prove how much I learned (not very much), I made this C calculator:
    #include <stdio.h>
    
    int main(void)
    {
        int numb1;
    	int numb2;
    	int numb3;
    	short oper;
    	
    	printf("Enter the first number. ");
    	scanf("%d", &numb1);
    	printf("Enter the second number. ");
    	scanf("%d", &numb2);
    	printf("Enter the ASCII operator (43 (adding), 45 (subtracting), 42 (multiplying), or 47 (dividing). ");
    	scanf("%d", &oper);
    	if (oper == 43)
    	{
    	    numb3 = numb1 + numb2;
    	}
        else if (oper == 45)
        {
            numb3 = numb1 - numb2;
    	}
    	else if (oper == 42)
    	{
    	    numb3 = numb1 * numb2;
    	}
    	else if (oper == 47)
    	{
    	    numb3 = numb1 / numb2;
    	}
    	else
    	{
    	    printf("You entered a wrong ASCII char.\n");
    	}
    	printf("The result is: %d", numb3);
    	return 0;
    }

    It works and I tested it.
    But it's not that good. :\
    Posted in: Computer Science and Technology
  • 0

    posted a message on C Help!
    Quote from nexekho »
    When you pass &i to scanf, you're saying "put it at the MEMORY ADDRESS of i". That's what & does; it gets the memory address of the specified variable. If you tried to pass "i", you'd tell scanf to overwrite memory address 0 with the number.

    Printf, on the other hand, expects the value, not the memory address. Remove the &.

    Thanks.
    It works now.
    Now the mods can lock the thread! :biggrin.gif:
    Posted in: Computer Science and Technology
  • 0

    posted a message on C Help!
    I'm making a program that asks for a number, and then tells you what number you entered.
    But when I enter a number, it just says 2293620 which is not the number I entered.
    Here is the source code:
    #include <stdio.h>
    
    int main(void)
    {
        int i = 0;
        printf("Please enter a number.\n");
        scanf("%d", &i);
        printf("You entered %d", &i);
        return 0;
    }

    What is wrong with the code? ;_;
    Posted in: Computer Science and Technology
  • 0

    posted a message on Java...
    Quote from MrQuizzles »
    Quote from poke41 »
    Quote from MrQuizzles »
    I'm adding spaces because they are different numbers. This is in postfix.

    So you are saying 6 7 8 - 3 = 3 4 5?
    Excellent logic.[/sarcasm]


    You don't have enough operators there. You need two more.

    6 7 8 - 3
    6 -1 3 ????

    Is this a new form of math?
    Posted in: Computer Science and Technology
  • 0

    posted a message on Java...
    Quote from MrQuizzles »
    I'm adding spaces because they are different numbers. This is in postfix.

    So you are saying 6 7 8 - 3 = 3 4 5?
    Excellent logic.[/sarcasm]
    Posted in: Computer Science and Technology
  • 0

    posted a message on Java...
    Quote from MrQuizzles »
    Quote from poke41 »
    Quote from MrQuizzles »
    Fun test to see if you know the first thing about implementing calculators:

    Evaluate the following:
    6 9 2 - 6 * 3 * + 7/ = ??

    That does not make mathematical sense.
    There are two missing integers.
    So I will replace the integers with 0s.
    692 - 18 = 674.
    674 * 0 = 0.
    0 + 7 = 7.
    7 / 0 = ERROR MALFUNCTION ERROR ERROR (undefined)
    So the answer would be undefined.
    EDIT: Silly madk, you switched the digits in 692! :tongue.gif:


    It makes perfect sense

    6 9 2 - 6 * 3 * + 7 / = ??
    6 7 6 * 3 * + 7 /
    6 42 3 * + 7 /
    6 126 + 7 /
    132 7 / = 18.857142857142857142857142857143

    Why are you adding the spaces?
    And what does * + mean?
    And it is not possible for a human to carry out this floating point.
    Posted in: Computer Science and Technology
  • 0

    posted a message on Java...
    Quote from Lahrmid »
    The point is, don't claim to be able to do things you're not capable of, yet.

    No offence, it's just something we all had to go through when beginning programming! :smile.gif:

    I am capable of making a text (console) calculator.
    But I can't do a GUI calculator.
    Posted in: Computer Science and Technology
  • 0

    posted a message on Java...
    Quote from MrQuizzles »
    Fun test to see if you know the first thing about implementing calculators:

    Evaluate the following:
    6 9 2 - 6 * 3 * + 7/ = ??

    That does not make mathematical sense.
    There are two missing integers.
    So I will replace the integers with 0s.
    692 - 18 = 674.
    674 * 0 = 0.
    0 + 7 = 7.
    7 / 0 = ERROR MALFUNCTION ERROR ERROR (undefined)
    So the answer would be undefined.
    EDIT: Silly madk, you switched the digits in 692! :P
    Posted in: Computer Science and Technology
  • 0

    posted a message on So I suddenly feel like making an esoteric language
    How's the tutorial goin'?
    Posted in: Computer Science and Technology
  • 0

    posted a message on So I suddenly feel like making an esoteric language
    Quote from madk »
    C is simple ._.

    I know.
    It's the lowest high-level language out there.

    Quote from madk »
    This is Hello, World! in BrainF*ck.

    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-]
    <.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.

    I think Gigyas has invaded the digital world now. 0_o
    Posted in: Computer Science and Technology
  • 0

    posted a message on So I suddenly feel like making an esoteric language
    My god.
    I don't understand this language at ALL.
    It's even more complicated than C...
    Posted in: Computer Science and Technology
  • 0

    posted a message on Car thread
    Quote from CG62 »
    Something with four wheels, doors, and a functioning engine and transmission is enough for me.

    Don't forget the steering wheel.
    And fuel.
    And *gets hit by lawnmower*
    Posted in: General Off Topic
  • 0

    posted a message on So I suddenly feel like making an esoteric language
    Quote from madk »
    M-Code shall be its name.

    There are 3 variations - 8 bit, 16 bit, and 32 bit. Read the readme for the differences, read reference.txt for the complete command set. Post any questions here if it's hard to understand and I'll do my best to clarify. Please note that it's not verified to be 100% bug free.

    Download

    What does the M stand for?
    Posted in: Computer Science and Technology
  • 0

    posted a message on Java...
    Quote from MrQuizzles »
    Quote from poke41 »
    Quote from Lahrmid »
    I have to say that I agree with madk on the notice that bad maths doesn't coexist with programming.

    On topic: Read a tutorial, apply what you learned. And guess what you should do next? Read another tutorial :smile.gif:

    But you can program a calculator using a programming language.


    Only a few people here could actually program a calculator. It's a lot harder than you think it is.

    I meant a text calculator.
    I can make one of those.
    Posted in: Computer Science and Technology
  • 0

    posted a message on So I wanted to learn C...
    Quote from madk »
    That I don't know. :/

    By run manually, I mean if I could run the compiler directly on Command Prompt.
    Posted in: Computer Science and Technology
  • To post a comment, please .