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

  • Thread starter Thread starter Marta
  • Start date Start date
  • Tags Tags
    Programming
AI Thread Summary
The discussion revolves around creating a C program to compute values of the formula y = 5 * (x/10)^3, where x ranges from -4 to 3 in increments of 0.5. The program must calculate corresponding y values, determine which y value is closest to 1, and print the x value that yields this closest y. Additionally, specific output messages are required based on the y value's sign, and the program should conclude with a message including the user's name. Initial attempts at coding reveal several syntax and logic errors, including incorrect use of data types and functions, highlighting the need for a solid understanding of C programming fundamentals. The importance of practice and learning from resources is emphasized for successful programming.
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
 
Back
Top