Help in C [minor issue]

Guys can you please find my mistake ?

its not printing "a" and "b". Assuming a chose 2 for all three initial variable, then "a" and "b" are suppose to be 100 and 100.

Here is my code [It's in C]:

#include
#include

int main()
{
double width = 0; double w = 0;
double height = 0; double h = 0;
double length = 0; double len = 0;
double A; double B;
double Area_of_Base;
double pi = 3.1415;


printf("Welcome to final Assignment.\nToday we will be building an Elliptical Horizontal Storage Tank.\n\n\n");

printf("Chose the width of your Elliptical Horizontal Storage Tank in meters [NOTE: WIDTH MUST BE GREATER THAN 0.]: \n");
scanf("%d", &width);
printf("Chose the height of your Elliptical Horizontal Storage Tank in meters [NOTE: HEIGHT MUST BE GREATER THAN 0.]: \n");
scanf("%d", &height);
printf("Chose the length of your Elliptical Horizontal Storage Tank in meters [NOTE: length MUST BE GREATER THAN 0.]: \n");
scanf("%d", &length);

/* This Part will be converting the length, height and width into centimeters, since the gauge reads in centimeters*/

len = length * 100;
w = width * 100;
h = height * 100;

printf("\nThe height in centimeters is %d.\n",h);
printf("The width in centimeters is %d.\n",w);
printf("The length in centimeters is %d.\n",len);
/*_______________________________________________*/
/*Calculating Focal Radii*/

A = w/2;
B = h/2;
printf("%d,%d", A, B);
Area_of_Base = A * B * pi;
printf("Area of Base is: %d", Area_of_Base);


return 0;
}

you know, people often confuse us with the homework board and other people sometims confuse us with /g/. You have managed to confuse us with both.
Congratz on your dumbass award.

I've helped people around on sci with physics, chem and math... /b/ gets summer fags during the summer. And Veeky Forums well Veeky Forums gets its students during the winter.

Now if you don't mind since you took the time to pass by, can you please find my flaw on why B is giving me 0

>its not printing "a" and "b".
you declared A and B as doubles. when you print them you write "%d, %d", which indicates integers. replace "%d, %d" with "%f, %f"

works fine for me

But I'm using a c++ compiler, so probably it's just a C problem and probably is right.

thank you.

>thank you.
no problem. why are you using a c++ compiler if you are programming C?

im using a C compiler, but i have no idea why it kept doing that when i write it like that it works though:

printf("%d cm\n",A);
printf("%d cm\n",B);

I'm not OP.
I just had my IDE open and decided to test OP's code.

>doesn't understand how to work with types
time to go back to K&R, asshole

dennis ritchie didn't die for this

>replace "%d, %d" with "%f, %f"

the scanf conversion specifier for a double needs to be %lf, not %f

the printf conversion specifier should also be %.nlf or %.nlf, where n is the number of decimal places desired in the output

%lf = long float
>not necessary

%.nlf also not necessary.

he is not all c++ compilers are c compilers.

lol I just realized that you said "C minor' like the musical key haha lol that's pretty SHARP of you (get it lol haha (lmao (xd)))

only on Veeky Forums

>not necessary

it is in > C99, moron

Hey guys OP here.

So as i read the question i noticed i need an algorithm. Now the professor is supposed to post the lecture notes on this algorithm, but he hasn't yet.

But i was wondering if anyone would like to solve this problem i would really appreciate it.

>I would have finished solving it but i need to wait for the prof to post the integration code:

Here is the question:


we look at inserting a measuring stick
that is already calibrated in units of 10 centimeters. This measuring gauge
can be inserted into an opening at the top of the tank and used to measure
the depth of the liquid in the tank.
Your task will be to write a C program to produce a table of values showing
the volume of liquid in the tank for each of the points on the gauge.
The output of your program (for the example above) should look like:
Depth 10 cm : Volume 1.19 cubic meters
Depth 20 cm : Volume 3.34 cubic meters
Depth 30 cm : Volume 5.99 cubic meters
. . .
Depth 380 cm : Volume 172.55 cubic meters
Depth 390 cm : Volume 174.66 cubic meters
Depth 400 cm : Volume 175.74 cubic meters
Methodology for Part 1:
If the tank has width W and height H (in centimeters), the focal radii of the
cross section are A = W/2 and B = H/2. Then the equation of the ellipse is:
X2/A2 + Y2/B2 = 1
To find the volume at given depth you should compute the cross-sectional
area of the tank for each given depth using a numerical integration
algorithm such as the trapezoidal method. Then multiply this by the length
of the tank.
You must use a general integration function and apply it to this
particular function. Do not write an integration function that is
specific to this problem. Do not use an analytic solution to integrate
the function.
Hint: It is probably easier to imagine the tank on its side so that the depth
gauge is inserted horizontally. If you do this you must express the equation
as a function of y and integrate that function.

ok then why does my code work now then ?

#include
#include
#include

int main()
{
double width = 0; double w = 0;
double height = 0; double h = 0;
double length = 0; double len = 0;
double A; double B;
double Area_of_Base;
double pi = 3.1415;


printf("Welcome to final Assignment.\nToday we will be building an Elliptical Horizontal Storage Tank.\n\n\n");

printf("Chose the width of your Elliptical Horizontal Storage Tank in meters [NOTE: WIDTH MUST BE GREATER THAN 0.]: \n");
scanf("%d", &width);
printf("Chose the height of your Elliptical Horizontal Storage Tank in meters [NOTE: HEIGHT MUST BE GREATER THAN 0.]: \n");
scanf("%d", &height);
printf("Chose the length of your Elliptical Horizontal Storage Tank in meters [NOTE: length MUST BE GREATER THAN 0.]: \n");
scanf("%d", &length);

/* This Part will be converting the length, height and width into centimeters, since the gauge reads in centimeters*/

len = length * 100;
w = width * 100;
h = height * 100;

printf("\nThe height in centimeters is %d.\n",h);
printf("The width in centimeters is %d.\n",w);
printf("The length in centimeters is %d.\n",len);
/*_______________________________________________*/
/*Calculating Focal Radii*/

A = w/2;
B = h/2;
printf("%d cm\n",A);
printf("%d cm\n",B);

>"ok then why does my code work now then?"
It doesn't. Try entering a non-integer real number as a variable. Pic related. For extra credit, explain why this happens.

Do your own homework, fucking brainlet

is it because it reads the 1.7 as 1m
i thought double meant decimal form numbers, just like floats ...

Using windows, kill yourself.

Nigga, do your own homework. You won't learn shit by asking people on Chinese image boards to solve it for you.

>double pi = 3.1415

>Help in C [minor issue]
/mu/ is over there

kek