Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // exemplo de calc que fiz pro meu brothe guinha
- #include <stdio.h>
- char line[100],operator;
- int result,value;
- char opcao_menu()
- {
- int i;
- char *banner[] = {
- "Operator Calc",
- "coded by Cooler_ ",
- "put with example",
- "operators:+,-,*,/ ",
- "(s)para Sair",
- "-> ",
- };
- for(i=0; i<=5; i++)
- printf(" %s \n",banner[i]);
- }
- int main()
- {
- opcao_menu();
- result = 0;
- while (1)
- {
- printf("Resultado: %d\n", result );
- printf("Digite Operador e o numero : ");
- fgets(line, sizeof(line), stdin);
- sscanf(line, "%c %d", &operator, &value);
- if ((operator == 's') || (operator == 'S'))
- break;
- if (operator == '+')
- result += value;
- if (operator == '/')
- result /= value;
- if (operator == '-')
- result -= value;
- if (operator == '*')
- result *= value;
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment