Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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

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...
 
Share this answer
 
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.
 
Share this answer
 
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.
 
Share this answer
 

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



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