Skip to content

Instantly share code, notes, and snippets.

@artemrogov
Last active September 22, 2016 14:23
Show Gist options
  • Save artemrogov/ce60a31b889daa876bd82f73808781e1 to your computer and use it in GitHub Desktop.
Save artemrogov/ce60a31b889daa876bd82f73808781e1 to your computer and use it in GitHub Desktop.
приметивный калькулятор на си, для Кости
#include<stdio.h> //библиотека ввода/вывода
//#include<stdlib.h> // библиотека для функции getchar() для линукца
#include<conio.h>
//
int main(){
int n,a,b,result;
char opt;
do {
printf("колавиша 1: сложение\n");
printf("колавиша 2: разность\n");
printf("колавиша 3: умножение\n");
printf("колавиша 4: деление\n");
printf("Введите число А:\n");
scanf("%d",&a);
printf("Введите число B:\n");
scanf("%d",&b);
printf("Введите операцию:\n");
scanf("%d",&n);
switch(n){
case 1: result = a+b;
printf("Сумма результат %d", result);
break;
case 2: result = a-b;
printf("Сумма результат %d", result);
break;
case 3: result = a*b;
printf("Сумма результат %d", result);
break;
case 4: result = a/b;
printf("Сумма результат %d", result);
break;
default: printf("Нет такой оперции");
}
printf("Для продолжения нажмите 1, для выхода 0\n");
scanf("%c",&opt);
}while(opt==1);
// getchar(); для винды
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment