Hello im just wondering how to do this?

I want to make a program that it can solve this a*x+b I just started so I don't know to do it can you please help me?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

using namespace std;

int main()
{
  float a;
  float x;
  // Now you fill in here how to create a variable named "b"

  cout << "Enter a: \n";
  cin >> a;
  cout << "Enter x: \n";
  cin >> x;
  // Now youfill in here how to get the value for "b"

  cout << "(a + x) /b = " << (a+x)/b;
  // Now you fix that so it does the right calculation
}

I'm using this #include <stdio.h>
That's C code. Can you not use C++ instead?
no, I can't I'm learning C that's why
Maybe like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>

int main()
{
  float a = 0, b = 0, x = 0, y = 0;
  
  printf("Enter a: ");
  scanf("%f", &a);
  printf("Enter b: ");
  scanf("%f", &b);
  
  /* 
   * TO DO 
   * calculate the value for y
   */

  printf("(%f + %f) / %f = %f", a, x, b, y);

  return 0;
}
didn't help me, man, what do you mean calculate the y?
Thomas1965 has shown you how to do the I/O using the C library.

Repeater has shown you how to do the maths.

Your task now is to look at the techniques they've shown you, and use what you've learnt to combine those techniques into a program of your own.
y is a*x+b, the variable holding the output. MikeyBoy didn't write the line to calculate y he wants you to do it yourself. You know how to assign a variable right? So assign the correct value to y using mathematical operators and the variables a, b and x that's all.


Topic archived. No new replies allowed.