Novo curso! Todo programador deveria aprender IA generativa!
+ 3

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
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
+ 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
+ 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
`Š½ŃŃįØā“ā°ā¶
+ 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
+ 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
+ 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
+ 2
22nd Apr 2024, 5:31 PM
Mafdi
+ 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
`Š½ŃŃįØā“ā°ā¶
+ 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
+ 2
Yesi Toro Run the code, still it has errors!
22nd Apr 2024, 6:24 PM
`Š½ŃŃįØā“ā°ā¶
+ 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
+ 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
22nd Apr 2024, 6:19 PM
Yesi Toro
+ 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
+ 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
`Š½ŃŃįØā“ā°ā¶
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
`Š½ŃŃįØā“ā°ā¶
0
I need help
24th Apr 2024, 12:11 PM
Jitendra Kushwaha
0