![]() |
| | #1 |
| Guest
Posts: n/a
| low value, high value and increment 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)); |
|
| | #2 |
| and the hat of vanishing 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;
}
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 | |
| | #3 |
| Guest
Posts: n/a
| 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. |
|
![]() |
| Thread Tools | |
| Display Modes | |
|