I need help please!!! | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
+ 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
20 ответов
+ 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
Good, please share your C code attempt
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