Show DevBest Calculator in C

Status
Not open for further replies.

Pro123

New Member
Feb 20, 2011
21
0
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;
}
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
Thanks
Also I might make some little tweaks to it to make it more professional :)
 

Dayron1234

Rapnameiszero,cuzIhavezero,toleranceforidiots
Jun 30, 2010
772
35
Isn't this C++ not C sharp(which is C# but people call it C or C sharp).
 
Status
Not open for further replies.

Users who are viewing this thread

Top