double pow (double x, double y) -- problems


 
Thread Tools Search this Thread
Top Forums Programming double pow (double x, double y) -- problems
# 1  
Old 10-03-2008
Error double pow (double x, double y) -- problems

This is the code and I'm wondering why line 14: a = ... and line 16: b = ... is wrong.

This is the first time I've tried to use this. Please help me.

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

// The link and how the double pow is used.
//
// http://www.nextdawn.nl/c-reference/pow.php
//
// double pow(double x, double y); 

int main (void)
{
    double x = 2.55;
    double a, A = 3.00, b, B = 2.00;
    double Z = 3 * a - 5 * b + 6;
    
    a = double pow (double x, double A);
    
    b = double pow (double x, double B);
    
    printf ("3x^3 - 5x^2 + 6 = %.2lf\n", Z);
    
    return 0;
}

# 2  
Old 10-03-2008
try this:
Code:
$ cat x.c
#include <stdio.h>
#include <math.h>

// The link and how the double pow is used.
//
// http://www.nextdawn.nl/c-reference/pow.php
//
// double pow(double x, double y);

int main (void)
{
    double x = 2.55;
    double a, A = 3.00, b, B = 2.00;
    double Z ;

    a = pow (x, A);

    b = pow (x, B);
    Z = 3 * a - 5 * b + 6;

    printf ("3x^3 - 5x^2 + 6 = %.2lf\n", Z);

    return 0;
}
$ gcc x.c -lm -o x
$ ./x
3x^3 - 5x^2 + 6 = 23.23
$

# 3  
Old 10-04-2008
Thanks

That was very helpful and I understand what I did wrong the first time.

Thank you very much.

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace Double quotes within double quotes in a column with space while loading a CSV file

Hi All, I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes. Sample Data : "221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies

2. Shell Programming and Scripting

Replacing Double Quote in Double Quote incsv file

Hi All , We have source data file as csv file and since data could contain commas ,each attribute is quoted into double quotes.However problem is that some of the attributa data also contain double quotes which is converted to double double quote while creating csv file XLs data : ... (2 Replies)
Discussion started by: Shalini Badal
2 Replies

3. Shell Programming and Scripting

Replace double quotes with a single quote within a double quoted string

Hi Froum. I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is. I have the following data: Before: ... (32 Replies)
Discussion started by: pchang
32 Replies

4. UNIX for Dummies Questions & Answers

double while

file1 contents: jandoe1 johndoe1 file2 contents: jandoe johndoe my output file names file3, and has contents as: This is jandoe1 my script: cat file1 | while read line1 cat file2 | while read line2 do do sed -e 's/${line1}/${line2}/g' file3 > file3 done done (5 Replies)
Discussion started by: lawsongeek
5 Replies

5. Shell Programming and Scripting

Replace double double quotes using AWK/SED

Hi, I have data as "01/22/97-"aaaaaaaaaaaaaaaaa""aaa""aabbbbbbbbcccccc""zbcd""dddddddddeeeeeeeeefffffff" I want to remove only the Consequitive double quotes and not the one which occurs single. My O/P must be ... (2 Replies)
Discussion started by: Bhuvaneswari
2 Replies

6. UNIX for Dummies Questions & Answers

Double space

Hi. this is my code: set common2 = "1 2 3 4" echo $common2 you can see that between 1 and 2 there is double space but the output is 1 2 3 4 and not 1 2 3 4 what is the problam??? (4 Replies)
Discussion started by: nirnir26
4 Replies

7. Programming

getting double to be converted

got a problem. i have to get A to + 20.70 but i keep getting A + 20 in my logic below. anyone can guide me on where i go wrong? i understand it is a double, but i do not noe how to parse it to the function so that it can read in as 20.70 instead of just 20.. i highlighted the problem part... (1 Reply)
Discussion started by: xiaojesus
1 Replies

8. Shell Programming and Scripting

double-quote inside double-quote

hey all, i made a simple .sh like this: echo "<style media="screen" type="text/css">@import url("main.css");</style>" but the output is: <style media=screen type=text/css>@import url(main.css);</style> i want to keep double-quotes, can anyone help me? thanks (3 Replies)
Discussion started by: indraf
3 Replies

9. Shell Programming and Scripting

problems with double quotes in PERL

I have a cgi script I run through apache2 and I need to have a line that contains double quotes within double quotes. Here's what I need PERL to pass to rrdtool: HRULE:30#BBBB00:"30.0 constant":dashesIt's a little more complicated since I also have variables in the statement which requires... (13 Replies)
Discussion started by: audiophile
13 Replies

10. Shell Programming and Scripting

double quotes

I have a file with 1 column and its data is as follows; "Happy Hour, Party on 18"" staged on 20th." Can anyone please suggest me how do I remove the embedded quote in data stage while reading this column. awk or sed might be able to do the trick . but i am not sure how to accomplish this. ... (4 Replies)
Discussion started by: pavan_test
4 Replies
Login or Register to Ask a Question