Programming Help: Solving y = 5 (x/10)3 for x - Marta

  • Thread starter Thread starter Marta
  • Start date Start date
  • Tags Tags
    Programming
Click For Summary

Discussion Overview

The discussion revolves around programming assistance for solving the equation y = 5 (x/10)^3 in C language. Participants are addressing the requirements of a program that computes y values based on x inputs and identifies which y value is closest to 1.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Marta requests help in writing a C program to compute y values from the formula and find the closest y value to 1.
  • Some participants inquire about the programming language and the specific areas of confusion.
  • Marta specifies the requirements for the program, including input values, output messages based on y values, and a final message upon completion.
  • One participant critiques Marta's initial code, pointing out syntax errors and logical issues, such as the misuse of brackets and the need for proper function calls.
  • Another participant emphasizes the importance of practice and reading in programming, suggesting that lack of effort may lead to difficulties in learning.

Areas of Agreement / Disagreement

There is no consensus on the correctness of Marta's code, as participants express differing views on its validity and the need for improvement. The discussion remains unresolved regarding the specific programming challenges faced by Marta.

Contextual Notes

Participants have noted various syntax and logical errors in the provided code, but the discussion does not resolve these issues or provide a corrected version of the code.

Marta
Messages
4
Reaction score
0
Can someone help me with this,
I have to write a program that computes values of a formula that expresses y in terms of x
the formula is y = 5 (x/10)3 ; the 3 is to the 10^3 .


also , my program need to find which of the y values is closest to 1 ( either larger or smaller ). then print the x value that gives this closest y value . Print how close the y value is to 1 .


Can someone please help me with this .
Marta
 
Computer science news on Phys.org
Which language is this for? What don't you actually understand?
 
c language

this is for C language . and I don't know how to write a program for these two tasks. which is whati need help with
 
And I assume this is for a class? We don't give help unless you show us some effort.
 
please help with this

using C I have to write a program to compute values of formula y=5(x/10)^3
1. I have to give my name
2.use values starting with -4 to 3 increase by 0.5
3.each value should compute the coresspoding y value
4. the message should say
if the value y is exactly 0 , the message shhould say y is zero.
if the value is + , the message should say y is +
if the value is - , the message should say y is -
5. once x=3 , the program should print a message ( underneath the last line of output ) giving my name and saying the program is halting. then stop


this is what I have done so far :

1./*program prog1c.c : print the formula y= [ (x/10) POW 3) *5] */
# include <stdio. h >
int main ( )
{
printf ( " Hello my name is Marta , this is the output of my first program")
table x , y ;
for (x = -4 ; x < = 3 ; x=x+0.5 );
y = [ (x/10) POW 3 ) * 5 ] {
printf ( "%f %f ", x ,y )
if ( = = ...this is where I got stuck. I don't know how to write the if values...can you please help and check my earlier work

MArta
 
You got to be kidding me. That code doesn't make any sense. Where did you define table? Do you know that the for loop isn't going to do anything? Square brackets are reserved for arrays, unless you overload the operator. pow is a function and requires (). You also need to include math.h. What are you doing sticking a { at the end of an assignment statement? I suggest you pick up a good c programming book and read it.
 
Besides all the syntax and logic errors that dduardo meantioned I would like to add the following:
Programming, like many things, requires a lot of practice and reading. Failure to practice, read the text, and show up for lectures when you're a novice will almost always result in failing the class.


Ryan
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
2
Views
2K
Replies
7
Views
2K
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
8
Views
5K