+ 3
I need help please!!!
So; m=20 K=5 g=9.8 we have the formula m*g=K*L, we need to find L. How do I code this in C???
21 Respuestas
+ 9
Can you solve it without coding?
Please share your code attempt.
hint: the opposite of multiplying is dividing.
+ 8
Yesi Toro integers hold only whole numbers. Variables m, K, and g should be defined as floating point.
+ 4
You're almost done Yesi Toro, just concentrate on those things in your code...
First there is a comma after g in the variable declaration section fixed this. It should be int m, K, g; and put your L to float like that float L;
Then fixed all your scanf function. The format specifier %d is need to be inside " " and I mean it should be like scanf("%d", &m);
Also fixed this like that:
printf("m*g/K = %f\n", L);
And finally, the return 0; should be one time not twice.
Fixed those Errors and run the code playground and share here like this⤵️
https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app
+ 4
Hello Jitendra Kushwaha, and welcome to Sololearn!
If you have a question on a different topic, then please start a new Q&A post. Be specific about the help you need. Describe the problem. Explain what you were expecting. Show what you have tried.
+ 3
L=m*g/K
So, L=20*9.8/5
L=196/5
L=39.2
+ 3
You can try this
#include <stdio.h>
int main() {
float m = 20; // mass
float K = 5; // constant
float g = 9.8; // gravity
// calculate L using the formula: m * g = K * L
float L = (m * g) / K;
printf("The value of L is: %.2f\n", L);
return 0;
}
+ 3
#include<stdio.h>
int m = 20, K = 5;
float g = 9.8, L;
L = (m * g) / K
+ 2
Good, please share your C code attempt
+ 2
Use this user define function to solve this in C:
L = (m * g) / K;
Theoretically Yesi Toro u already solved the question by your own. Do this in the C code and share here!
+ 2
#include <stdio.h>
int main() {
int m, K, g, ;
scanf("%*d , &m");
scanf("%*d , &K");
scanf("%*d , &g");
printf("Entered the value of m = %d\n", m);
printf("Entered the value of K = %d\n", K);
printf("Entered the value of g = %d\n", g);
int L = m*g/K;
printf(“m*g/K = %d\n” , L);
return 0;
return 0;
}
+ 2
Yesi Toro Run the code, still it has errors!
+ 2
* Declare m,K,g and initialize them with their respective value
* Then declare a float variable L which is our result value
* Initialize L value by using:
L = (m*g)/K
+ 1
I wrote this but I just got introduced to c language, yesterday in school but we didn't have any examples of how to do anything. I need this for homework.
+ 1
`нттp⁴⁰⁶ okay I deleted it, but he did good efforts, will he learn everything by his own as a beginner and with C language!
Many teachers also tend to use unethical approaches, they don't teach well and just throw random homeworks.
+ 1
#include <stdio.h>
int main() {
// Declare variables
float m, K, g, L;
m = 20;
K = 5;
g = 9.8;
L = (m * g) / K;
printf("The value of L is: %f\n", L);
return 0;
}
0
Mafdi I think to give this kind of solution shouldn't be provided for homework problems. We can provide solution for this. But let the guy help to teach how to solve his own problem by own effort. You should let them fixed their own problem coz it is not ethical you provide someone's homework solution.
0
That's a good point but I think the rest of his mistake will be solved by his class teacher not we. If not there we are. Let's see what happens.
Thanks a lot Mafdi
0
I need help
0
Can l help you