15,904,416 members
See more:
i hate to rite a program that determines the solution of a degree 1 equation with real coefficients, of the form ax+b = 0

i wrote

```#include <stdio.h>
int main(){
int a , b , x ,result;
scanf("%d %d %d", &a ,&b ,&x);
result = a*x + b = 0;
printf("The solution is %d" , );
return 0;
}```

i dont think is correct to write result=a*x + b =0 ; but i dont know how to write the right algorithm.

What I have tried:

i m new to programming sorry i need some help
Posted
Updated 19-Nov-22 12:29pm

## Solution 1

This sounds like a homework assignment... I will get you started on how to solve the equation:

I did a quick Google Search: ax b = 0 - Google Search[^] and found this: How do you solve for x in ax+b=0? | Socratic[^]

Now you can write the code...

## Solution 2

Quote:
i hate to rite a program

I suppose it is "I have to write".
you are writing a question for others, make it clear. Pay attention to spelling.
Quote:
determines the solution of a degree 1 equation with real coefficients, of the form ax+b = 0

Read carefully the requirement !
In this case, you want to find x.
C++
`result = a*x + b = 0;`

The language will not guess what you want to do. This code is correct c, but it have another meaning.

The requirement wants you to find the mathematics to solve the equation by hand, and then translate this mathematic to a program.

## Solution 3

Quote:
determines the solution of a degree 1 equation with real coefficients, of the form ax+b = 0

As Patrice has already pointed out, this type of task usually looks for a solution for the variable x. So you have to read in a and b and rearrange the formula so that the value for x comes out as the result.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Richard Deeming 100 Pete O'Hanlon 75 OriginalGriff 60 CPallini 40 Red Kipling 34
 Pete O'Hanlon 1,715 OriginalGriff 1,307 Richard Deeming 545 Dave Kreskowiak 415 Richard MacCutchan 355

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900