Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<locale.h>
- #include<ctype.h>
- int main(){
- setlocale(LC_ALL, "Portuguese");
- int x, y;
- char esc;
- printf("Digite X: ");
- scanf("%d", &x);
- setbuf(stdin, NULL);
- printf("Digite Y: ");
- scanf("%d", &y);
- setbuf(stdin, NULL);
- do{
- printf("\nEscolha\n\nA - Adição\nS - Subtração\nM - Multiplicação\nD - Divisão\n");
- scanf("%c", &esc);
- setbuf(stdin, NULL);
- esc = tolower(esc);
- }while(esc != 'a' && esc != 's' && esc != 'm' && esc != 'd');
- switch(esc){
- case 'a' : printf("%d + %d = %d", x,y,x+y);
- break;
- case 's' : printf("%d - %d = %d",x,y,x-y);
- break;
- case 'm' : printf("%d * %d = %d",x,y,x*y);
- break;
- case 'd' : if (y==0) printf("Invalido, denominador = 0");else printf("%d / %d = %.2f",x,y,(float)x/y);
- break;
- }
- }
Add Comment
Please, Sign In to add comment