+ 2
Why i dont get the value of gs
9 Answers
+ 5
Is this what you want?
#include<stdio.h>
#include<conio.h>
int main()
{
float a;
float b,c,gs;
printf("enter the value of a");
scanf("%f",&a);
b=40/(100*a);
c=20/(100*a);
gs=a-(b+c);
printf("\n%f",gs);
return 0;
}
+ 15
scanf( )
To read an integer, use either the %d or %i specifier.
To read a floating-point number represented in either standard or scientific notation, use %e, %f, or %g.
printf( )
You may use either %d or %i to indicate a signed decimal number.
The %f format specifier displays numbers in floating point.
+ 3
I am not sure about your calculation:
b = (40/100)*a
or 40/(100*a)
+ 3
Thanks bro
+ 3
if you use a as int you get b = 0 after the calculation. Same for c.
So gs = a - (b + c) = a - 0 = a.
+ 2
* you need a line break
* for float use %f not %d
Can you give an example of an input and an expected output?
+ 2
Can you do this for me
+ 2
Why I can't use the value of a as int