+ 1

Someone help automate this question I ran my code but seemingly has a logical error it runs but the answer is not satisfying

question is w=(a-b+√c/k^10)/17a

31st Oct 2021, 5:30 AM
Kelvin Kiprop Kemboi
Kelvin Kiprop Kemboi - avatar
13 Antworten
+ 3
Kiprop Kelvin change w to float data type. This formula results comes in decimal point
31st Oct 2021, 6:23 AM
Azhagesanヾ(✿)
Azhagesanヾ(✿) - avatar
+ 3
Kiprop Kelvin In C ^ known as Bitwise exclusive OR and in mathematics it's power so this operator can't be use as power in programming language. To get power you have to use function pow()
31st Oct 2021, 6:11 AM
A͢J
A͢J - avatar
+ 2
Kiprop Kelvin Yes but you can't change formula. You are multiplying instead of dividing Program will automatically follow that rule in programming language () has higher precedence https://code.sololearn.com/clgEHN8nvt7l/?ref=app
31st Oct 2021, 6:07 AM
A͢J
A͢J - avatar
+ 1
Where is your solution?
31st Oct 2021, 5:37 AM
A͢J
A͢J - avatar
+ 1
#include<stdio.h> #include<math.h> int main() { int a,b,c,k,w; printf("Enter value of a:"); scanf("%d",&a); printf("Enter value of b:"); scanf("%d",&b); printf("Enter value of c:"); scanf("%d",&c); printf("Enter value of k:"); scanf("%d",&k); w=(((sqrt(c))/((k^10)*17*a)+(a-b))); printf("w is equals to %d", &w); }
31st Oct 2021, 5:41 AM
Kelvin Kiprop Kemboi
Kelvin Kiprop Kemboi - avatar
+ 1
There it is
31st Oct 2021, 5:41 AM
Kelvin Kiprop Kemboi
Kelvin Kiprop Kemboi - avatar
+ 1
Kiprop Kelvin According to formula you have to divide by 17 * a but you are multiplying There is (a - b + sqrt(c) / pow(k,10)) / (17 * a)
31st Oct 2021, 5:58 AM
A͢J
A͢J - avatar
+ 1
Thanks for your answer I think thats what I needed
31st Oct 2021, 6:25 AM
Kelvin Kiprop Kemboi
Kelvin Kiprop Kemboi - avatar
+ 1
Kiprop Kelvin When you divide lower integer value with higher integer value then you will always get 0 since power of 10 is higher so when you divide you get 0.
31st Oct 2021, 6:37 AM
A͢J
A͢J - avatar
+ 1
Okay thanks
31st Oct 2021, 6:42 AM
Kelvin Kiprop Kemboi
Kelvin Kiprop Kemboi - avatar
0
But again it is necessesary that it follows BODMAS or rather operator precedence
31st Oct 2021, 6:05 AM
Kelvin Kiprop Kemboi
Kelvin Kiprop Kemboi - avatar
0
Okay about the power function that I have well understood I have went and keyed in your code that you've given me and apparently it kinda gives zero as the result despite my change of variables quite a number of times but thanks for that
31st Oct 2021, 6:16 AM
Kelvin Kiprop Kemboi
Kelvin Kiprop Kemboi - avatar
0
I don’t have a good foundation in English .can you help me? Thank you
31st Oct 2021, 12:27 PM
鹏业 陆