Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int simple_multiply(void)
- {
- int a, b;
- int ret;
- ret = scanf("%d %d", &a, &b);
- int tulos = a * b;
- printf("%d\n", tulos);
- return 0;
- }
- float simple_math(void)
- {
- float n1, n2;
- char operaattori;
- float tulos;
- int ret;
- ret = scanf("%d, %c, %d", &n1, &operaattori, &n2);
- if (operaattori == '+')
- {
- tulos = n1 + n2;
- printf("%.1f\n", tulos);
- }
- else if (operaattori == '-')
- {
- tulos = n1 - n2;
- printf("%.1f\n", tulos);
- }
- else if (operaattori == '/')
- {
- tulos = n1 / n2;
- printf("%.1f\n", tulos);
- }
- else
- {
- printf("ERR\n");
- }
- return 0;
- }
- int main(void)
- {
- /*simple_multiply();*/
- simple_math();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement