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
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😭😭
+ 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.
+ 1
Avinesh yes the last one works well thanks a lot🙋🏻♀️🙋🏻♀️🙋🏻♀️
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.
0
Avinesh i checked it for 10,5 it worked but for 10,0 it didn’t
0
~ swim ~ i’m trying,i want to do my best,but i need help , because our exam is next week💔