C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-24-2001, 08:08 PM   #1
Unregistered
Guest
 
Posts: n/a
low value, high value and increment

Hello CProgrammers,

Future programmer need help with a code. I am to design a program that reads a low value, a high value and increment value, ensure that the low value is less than or equal to the high value and computes and prints a table of square roots and cubic roots for all values of low and high at increments of increment.

If the value of low, high and increment are 1, 1.55 and 0.1 the table should look like:

Value Square Root Cubic Root
1.0 1.0 1.0
1.1 1.04881 1.03228

and so on....
Here is the code that I have done and I am having problems working pass this point, any help will be greatly appreciated!
CODE : (oh, how do you all put the code in small print so it could be easily understood..)


# include <stdio.h>
# include <math.h>

double sqrt(double x);
double pow (double x, double y);
int main(void) }

/*variable declarations*/
double low_value,high_value,increment;

printf("ENTER LOW VALUE: ");
scanf("%1f", &low_value);
printf("ENTER HIGH VALUE: ");
scanf('%1f, &high value);
while (high_value <= low_value) {
printf("*****RE ENTER VALUES*****\n");
printf("ENTER LOW VALUE:" )
scanf("%1f", &low_value);
printf("ENTER HIGH VALUE:" );
scanf("%1f, &high_value);
}
printf("\n");
printf("VALUE SQUARE ROOT CUBIC ROOT\n");
printf("----- ----------- ----------\n");
printf("%f, low value);
printf(" %f", sqrt(low_value)),
printf(" %f\n", pow(low_value,.33333));
increment=0.1;
do}
low value=low value+increment;
printf("%1f", low_value);
printf(" %f", sqrt(low_value));
  Reply With Quote
Old 11-25-2001, 02:18 AM   #2
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
First off, you get a compiler, and you figure out how to use it

> int main(void) }
I mean, what is this all about?

> double sqrt(double x);
> double pow (double x, double y);
These are already in math.h, you don't need to say it twice

Then you start here
Code:
#include <stdio.h> 
#include <math.h> 

int main(void) {
    /*variable declarations*/ 
    double low_value,high_value,increment; 

    printf("ENTER LOW VALUE: "); 
    scanf("%lf", &low_value);
    printf( "You entered %f\n", low_value );

    return 0;
}
Having got this working, you add your code a few lines at a time (say 5 max), and you make sure it COMPILES AND WORKS before rushing into the rest of the program.

Writing a whole mess of code, and hoping it will all work (or you'll get someone on a message board to fix it) isn't going to happen.

For what it's worth - you've got most of the bits - it just needs sorting out so it will compile.

> (oh, how do you all put the code in small print so it could be easily understood..)
You read this link
vB Code [help]
http://www.cprogramming.com/cboard/m...bbcode#buttons
Salem is offline   Reply With Quote
Old 11-25-2001, 09:01 AM   #3
Unregistered
Guest
 
Posts: n/a
Wink

Wow Salem! you do know how to show TOUGH LUV Thanks!
I will go to my room and work on this code and thanks for the link.
  Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 03:08 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22