+ 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

13 Answers

+ 3

Kiprop Kelvin change w to float data type. This formula results comes in decimal point

+ 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()

+ 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

+ 1

Where is your solution?

+ 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);
}

+ 1

There it is

+ 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)

+ 1

Thanks for your answer I think thats what I needed

+ 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.

+ 1

Okay thanks

0

But again it is necessesary that it follows BODMAS or rather operator precedence

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

0

I don’t have a good foundation in English .can you help me? Thank you