N
N
Neo_hacker2018-10-03 13:38:08
C++ / C#
Neo_hacker, 2018-10-03 13:38:08

How to express a formula in C?

There is a formula for determining speed: V=S/t
In C I get values ​​and one of them is not known.
printf("V="); scanf("%d", &v);
printf("S="); scanf("%d", &s);
printf("t="); scanf("%d", &t);
And if any of them is missing, I have to find it by expressing the formula.
I don't want to hardcode it using if for every formula. Is it possible to do it without them?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Griboks, 2018-10-03
@Griboks

As many as three ifs. What a hardcode! Not like libraries of symbolic calculations.

I
Ivan Klimenko, 2018-10-03
@yeswell

Using the three lines of code you wrote, you will not be able to NOT enter some value. First you need to deal with this. And in any case, you will have to use either if or switch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question