473,803 Members | 4,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need to help,I couldnt find wrong

/////////////////////// DIVISION FUNCTION ////////////////////
void div ( int pol1[] , int pol1p[] , int pol2[] , int pol2p[])
{
int r=5,z,i,g,j,k,l ,dividend[6],rising[6]={0};
for (i=0 ; i<6 ; i++)
dividend[i]=pol1[i];
for(i=5 ; i >=0 ; i--)
{
r=5;
for(z=r ; z>=0 ; z--)
{

if(pol2[z]!=0)
{
*(po5 + (i-z))= dividend[i]/pol2[z];
for(l=0; l<6; l++)
rising[l]=0;
for (j=z ; j>=0 ; j--) {
rising[i+j-z] = (*(po5 + i-z) * pol2[j]);
}
for(k=0; k<6 ; k++) {
dividend[k] = dividend[k] - rising[k];
}

}
r=z-1;
}
}
for (i=0 ; i<6 ; i++) {
printf("%dX^%d+ ",*(po5+i), i);
}

when first poly is like 3X^2 and second poly is like 1X its work
right, but it divides other poly wrongly, I couldnt find,helppp me
pleaseee
Nov 16 '07 #1
5 1317
emre esirik(hacettep e computer science and engineering) wrote:
[yet another request that we correct his coursework...]

Is C actually the most appropriate tool for what he's trying to do?

(I've been working with C for over 10 years and never done any
polynomial manipulation)

Might there be better alternatives?
Nov 16 '07 #2
its my homework, I am studying at hacettepe university and we are
learning C language for a mounth and this is my 5.homework which I
have to do coding for poly :
„h Addition
„h Subtraction
„h Multiplication
„h Division
„h Derivation
„h Integration

-------The input will be in the following format:
ADD 3X^2+4X^1+7 2X^2+5
SUB 3X^2+4X+7 2X+5
DIV 3X^2+4X+7 X+3
MUL 3X^2+4X+7 X+3
DER 3X^4+4X^2+5X+7
INT 3X^2+4X+7

so I just trying to solve poly division, couldnt help me?
Nov 16 '07 #3
Mark Bluemel said:
emre esirik(hacettep e computer science and engineering) wrote:
[yet another request that we correct his coursework...]

Is C actually the most appropriate tool for what he's trying to do?
It's an entirely appropriate tool, yes. Polynomial manipulation is just a
series of operations on array members. For example, I would do simple
integration something like this (and please understand that this is
off-the-cuff untested code):

struct term_
{
double factor;
double power;
};

typedef struct term_ term;

int integrate(term *t, size_t n)
{
int rc = 0; /* use this to report sillies eg /0 */
while(n-- 0)
{
++t->power;
t->factor /= t->power;
++t;
}
return rc;
}

If the powers started getting bizarre (e.g. e^(i*pi)), then yes, okay,
that's a bit harder, but for simple polynomials of the form ax^n +
bx^(n-1) + ... + px^1 + qx^0 = y, I don't think that's such a difficult
thing to do in C, even at the student level.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 16 '07 #4
I am sorry but I couldnt make me clear, I did integrate, I just only
couldnt do division, its difficult for me
Nov 16 '07 #5
emre esirik(hacettep e computer science and engineering) said:
I am sorry but I couldnt make me clear, I did integrate, I just only
couldnt do division, its difficult for me
No, you were very clear. My reply was directed at Mark, not at you. He
wanted to know whether C was the right tool for the job. I think he thinks
this is harder than it really is.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 16 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
610
by: Goofy | last post by:
Hi, i am having trouble getting sopmething simple working -a administration function where u can add topic and i cant see why.when i do to add a topc it shows me the message Error!. - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 the code i am running is this
8
2338
by: Kamil | last post by:
i dont know what i'm doing wrong i'm trying to get all the fields from a specific row by user name i'm using php and i got the connection string down and i made a query like this: $query = mysql_query("SELECT * FROM <DBname> WHERE name = $_POST"); the variable $_POST was passed to the php code from a previous html form i get the error: Unknown column '<username here>' in 'where clause'
4
1799
by: Jim Langston | last post by:
I understand the rule of three, that if I have a custom constructor, copy or destructor I probably need the other 2. My class object definately has a custom constructor and destructor, but I'm fuzzy on copy. Could someone help me out with this class? Shown are the variables, constructors and destructor only (rest snipped out to preserve space). Yes, I realize this is fairly ugly code, any suggestions/critiques on that would be...
31
2649
by: mark | last post by:
Hello- i am trying to make the function addbitwise more efficient. the code below takes an array of binary numbers (of size 5) and performs bitwise addition. it looks ugly and it is not elegant but it appears to work. using time, i measured it takes .041s to execute, which i admit isnt much. but, the problem is that this procedure will be called many, many times in my project (probably at least a few thousand times, if not more) so...
7
1560
by: pillip | last post by:
I am trying to use fopen and fget to input two files and then output them into one file. Each input file has two columns and 20 rows, however since the first column in each input file is same ( numbers 0...19), i want the output file to have 3 columns and 20 rows. Right now i am using a one dimensional array "array1" to input each file:, and the output file has 2 columns and 42 rows. #include <stdlib.h> #include <stdio.h>
4
2763
by: georges the man | last post by:
hey guys, i ve been posting for the last week trying to understand some stuff about c and reading but unfortunaly i couldnt do this. i have to write the following code. this will be the last time i ask for an entire code or u can give me the outine of what to do and i ll do it by myself. the description is the following: the program will read a text file that contains historical price of a stock. The program will allow users to query...
12
3020
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed the instructions and couldnt get the correct results. heres the code stuff... temperature=input("what is the temperature of the spam?") if temperature>50: print "the salad is properly cooked." else:
0
779
by: giridharan | last post by:
Hai In my project im using Simple editor that has been designed in c# code behind(Dynamically) for that im using HtmlGeneric Control,The problem is that im applying all my styles like bold ,italic and some more properties using Javascript its working Fine,But when i attempt to save the content i couldnt.in htmlgeneric control i couldnt get the new value using innertext or innerhtml.so please help me out to sort this out. ...
2
1064
by: droskies420 | last post by:
this is what my roster page for my website looks like at clan33.net/roster if any one can help me move it up and to the right that would be so great i couldnt thank you enough <tr> <td><table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left-content-t"><table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="content-header"> <div...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.