I need help please!!! | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
+ 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???

22nd Apr 2024, 4:47 PM
Yesi Toro
Yesi Toro - avatar
20 Respostas
+ 9
Can you solve it without coding? Please share your code attempt. hint: the opposite of multiplying is dividing.
22nd Apr 2024, 5:13 PM
Mafdi
Mafdi - avatar
+ 8
Yesi Toro integers hold only whole numbers. Variables m, K, and g should be defined as floating point.
22nd Apr 2024, 6:11 PM
Brian
Brian - avatar
+ 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
22nd Apr 2024, 6:15 PM
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂ - avatar
+ 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.
24th Apr 2024, 2:17 PM
Brian
Brian - avatar
+ 3
L=m*g/K So, L=20*9.8/5 L=196/5 L=39.2
22nd Apr 2024, 5:25 PM
Yesi Toro
Yesi Toro - avatar
+ 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; }
24th Apr 2024, 1:41 AM
Suhani Kewat
+ 3
#include<stdio.h> int m = 20, K = 5; float g = 9.8, L; L = (m * g) / K
24th Apr 2024, 3:42 PM
Parv
Parv - avatar
+ 2
Good, please share your C code attempt
22nd Apr 2024, 5:31 PM
Mafdi
Mafdi - avatar
+ 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!
22nd Apr 2024, 5:59 PM
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂ - avatar
+ 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; }
22nd Apr 2024, 6:00 PM
Yesi Toro
Yesi Toro - avatar
+ 2
Yesi Toro Run the code, still it has errors!
22nd Apr 2024, 6:24 PM
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂ - avatar
+ 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
24th Apr 2024, 10:12 AM
Aravind
Aravind - avatar
+ 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.
22nd Apr 2024, 6:02 PM
Yesi Toro
Yesi Toro - avatar
+ 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.
23rd Apr 2024, 1:02 AM
Mafdi
Mafdi - avatar
+ 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; }
10th May 2024, 11:49 AM
Syed Naqi Abbas
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.
22nd Apr 2024, 11:06 PM
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂ - avatar
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
23rd Apr 2024, 3:51 AM
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂
`–Ĺ—ā—āŠč®‚Āī‚Āį‚Ā∂ - avatar
0
I need help
24th Apr 2024, 12:11 PM
Jitendra Kushwaha
Jitendra Kushwaha - avatar
0
Can l help you
28th Apr 2024, 11:38 AM
Jitendra Kushwaha
Jitendra Kushwaha - avatar