+ 2
30th May 2019, 4:38 PM
Praveen Mishra
9 Réponses
+ 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; }
30th May 2019, 5:41 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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.
30th May 2019, 5:56 PM
MeanMachine
MeanMachine - avatar
+ 3
I am not sure about your calculation: b = (40/100)*a or 40/(100*a)
30th May 2019, 5:43 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
Thanks bro
30th May 2019, 5:43 PM
Praveen Mishra
+ 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.
30th May 2019, 5:47 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
* you need a line break * for float use %f not %d Can you give an example of an input and an expected output?
30th May 2019, 5:05 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Can you do this for me
30th May 2019, 5:09 PM
Praveen Mishra
+ 2
Why I can't use the value of a as int
30th May 2019, 5:44 PM
Praveen Mishra