Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculator in C
#1
Hi SF,

I made a little calculator, like Xenocide but in C and I made it like 3 weeks ago but here it is:

Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int equation, nombre1, nombre2, resultat, calculator=1;
    printf("Calculator in C by So.Liberty\n\n");
    while(calculator){
    printf("Which operation would you like to do?\n\n");
    printf("1. Addition\n");
    printf("2. Substraction\n");
    printf("3. Multiplication\n");
    printf("4. Division\n");
    scanf("%d", &equation);
    if(equation ==1)
    {
        printf("\n\nAddition\n\n");
        printf("Enter the first number:\n");
        scanf("%d", &nombre1);
        printf("Enter the second one:\n");
        scanf("%d", &nombre2);
        resultat=nombre1+nombre2;
        printf("There you go: %d", resultat);
        printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
        scanf("%d",&calculator);
    }
    else if(equation==2)
    {
        printf("\n\nSubstraction\n\n");
       printf("Enter the first number:\n");
        scanf("%d", &nombre1);
        printf("Enter the second one:\n");
        scanf("%d", &nombre2);
        resultat=nombre1-nombre2;
        printf("There you go: %d", resultat);
        printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
        scanf("%d",&calculator);
    }
    else if(equation==3)
    {
        printf("\n\nMultiplication\n\n");
        printf("Enter the first number:\n");
        scanf("%d", &nombre1);
        printf("Enter the second one :\n");
        scanf("%d", &nombre2);
        resultat=nombre1*nombre2;
        printf("There you go: %d", resultat);
        printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
        scanf("%d",&calculator);
    }
    else if(equation==4)
    {
        printf("\n\nDivision\n\n");
        printf("Enter the first number:\n");
        scanf("%d", &nombre1);
        printf("Enter the second one:\n");
        scanf("%d", &nombre2);
        resultat=nombre1/nombre2;
        printf("There you go: %d", resultat);
        printf("\n\nWould you like to do another operation?(1 for yes / 0 for no)\n\n");
        scanf("%d",&calculator);
    }
    else
    {
        printf("Go away if you don't like mathematics");
    }}
    return 0;
}
[Image: f_pgfbb4em_bde9974.png]
Reply
#2
For what is
scanf?
Reply
#3
(12-10-2009, 11:20 AM)bTwornR Wrote: For what is
scanf?

http://lmgtfy.com/?q=scanf
[Image: sig.php]
The little boat gently drifted across the pond exactly the way a bowling ball wouldn't.
Reply
#4
(12-10-2009, 11:20 AM)bTwornR Wrote: For what is
scanf?

If you get into C programming you will understand what scanf is and everything.
Reply
#5
if you can?....plz modefy to C++ coding

[Image: ubuntu_5.11.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multi Purpose Calculator Reality 21 5,064 12-14-2010, 06:11 PM
Last Post: Buzz Lightyear
  my own calculator WHITE PANDA 8 2,167 07-14-2010, 03:19 PM
Last Post: Kondry
  Calculator v1 Brainless Control 21 5,192 01-18-2010, 10:34 PM
Last Post: Equinøx

Forum Jump:


Users browsing this thread: 1 Guest(s)