0

Main operations

I want to write a code which take a,b then calculate one of these(- + / *) main operations and say the result But i can’t What can i do?! https://code.sololearn.com/ciW9hITUNheS/?ref=app

6th Nov 2019, 2:28 PM
Laya Mousavi
7 ответов
+ 1
~ swim ~ i know,i’m sorry about these silly questions i have to post these exercises to my teacher but i can’t solve them😭😭
6th Nov 2019, 4:30 PM
Laya Mousavi
+ 1
if(b==0) printf("error\n"); else{ int q=a/b; printf("%d\n",q); } Laya Mousavi Do this and you are good to go. Just make this change in loop.
6th Nov 2019, 4:31 PM
Avinesh
Avinesh - avatar
+ 1
Avinesh yes the last one works well thanks a lot🙋🏻‍♀️🙋🏻‍♀️🙋🏻‍♀️
6th Nov 2019, 4:49 PM
Laya Mousavi
0
#include <stdio.h> #include <math.h> int main() { int a,b; printf("what do you want to do?\n"); scanf("%d%d",&a,&b); int q=a/b; if(b==0) printf("error\n"); else printf("%d\n",q); int p=a+b; int m=a-b; int s=a*b; printf("%d\n%d\n%d",p,m,s); return 0; } This works? This is your code I have just made some changes so that you can see the output atleast. Parenthesis after if continuing till the end of else was wrong.
6th Nov 2019, 2:40 PM
Avinesh
Avinesh - avatar
0
Avinesh i checked it for 10,5 it worked but for 10,0 it didn’t
6th Nov 2019, 4:26 PM
Laya Mousavi
0
~ swim ~ i’m trying,i want to do my best,but i need help , because our exam is next week💔
6th Nov 2019, 4:51 PM
Laya Mousavi
0
Avinesh ~ swim ~ would you help me with my both last questions,please?!
7th Nov 2019, 8:12 AM
Laya Mousavi