C++ :: Identify Polynomial With Two Arrays Of Same Length

Oct 15, 2014

I wanna write a class for polynomials, but there are some bugs in my code. I want to identify a polynomial with two arrays of the same length, one that contains the exponents of the nonzero monomials, and the other that contains the coefficients itself.

for example: (shematically)
3x^2 +5x^100 shoud be identified by array1=(2,100) and array2=(3,5)

the size of that polynomial should be Dim=2.

it should be possible to change the size dynamically.

Code:

#ifndef poly
#define poly
#include<cassert>
class poly {

[Code] ....

PROBLEM1 the destructor isnt working:
virtual ~poly() {delete [] start;delete [] koef;} //destruktor
Error: This declaration has no Storage class or typ specifier.
Error: Expected an identifier.

PROBLEM2 the constructor isnt working:
poly::poly(int x=0)
Error: Expected an identifier
Error: Expected a )
Error: Expected a ;.

I dont know what the computer want to tell me??

View 6 Replies


ADVERTISEMENT

C :: Creating Variable Length Arrays

Oct 24, 2014

How do you prompt the user to enter the number of elements for the array and use that information to creatr a variable length array? And then how do you prompt the user to enter in a number for each element of the array and scan in the appropriate numbers? the numbers are double precision floating point.

for example,
Enter the numbe of elements in the array: 3
Enter element 0: 3
Enter element 1: -1
Enter element 2: 4

I know it starts with

int main() {
double N;
int a[size];

printf("Enter the number of elements in the array:" );
scanf("%f", &size);

//I'm pretty sure this is wrong

View 8 Replies View Related

C :: Why To Set Length Of Inner Arrays Declaring A Function

Oct 23, 2013

I'm just wondering, why you have to set the length of the inner arrays declaring a function. In which moment does the code needs to be sure about the length of the inner arrays accessing an cell?

I came up with this question realizing the elements of the outer array beeing pointers to the first value of each inner array. Therefore I can access e.g. the first first element of the second inner array like this:

**(arr + 1) ...regardless of the length of any array to my mind.

parallel post: [URL]...

View 6 Replies View Related

C++ :: Identify Floating Or Alphabets

Apr 28, 2013

I have this homework where i am implementing a code which does error checking

so basically i have 3 variables and i assigned them as integer. so my error check is asking that if i type a value for instance 1.2 it should output "X"...

View 19 Replies View Related

C/C++ :: Have To Identify Odd Number And Print Them

Apr 10, 2013

#include<stdio.h>
#define TRUE 1  
int formOddInt(int n);  

[Code]....

View 5 Replies View Related

C++ :: Identify End Of Function Code At Running Time

Apr 16, 2013

I want to implement some "debugger like" tool (very limited one, just identify at running time the current stack trace, and print messages from the user) on some code that the user wrote. what I get from the user is a function name (in the beginning of it's declaration), and when the user want to print some message he uses some print macro I should implement.

My target is printing the stack call, and all the messages that the user wrote, in the right place on the running place.

By what c++ feature can know on running time that a specific function code has ended??

Its easy to push a function to some vector when it called (since I get its name from the user), but when it ends and return to the function called it...

View 14 Replies View Related

C++ :: Identify Correct Function Pointer From Vtable?

Jan 21, 2013

We know that function pointer for virtual function are stored in a vtable.When we have multiple function pointer entry in vtable and we call one of the virtual function then how the corresponding or correct function pointer is retrived from Vtable? Who do this stuff? In assembly code i can not see any code or logic to detrmine the correct function pointer.

View 4 Replies View Related

Visual C++ :: Identify Which Of Two Subclassed Controls The Mouse Is Over?

Feb 11, 2013

I have a dialog app with two separate static controls. Both controls have been subclassed from CStatic derived class to implement drag and drop and double clicking. The class works just fine, but I cannot figure out which of the controls is being double clicked or dragged and dropped onto because I only have the code below operating. I need some method in the derived class to determine which control is being manipulated.

Code:
// header file
#pragma once
#ifndef __AFXWIN_H__

[Code]....

View 3 Replies View Related

C :: Identify The Invalid Expression - All Variables Are Integer And Nonzero

Feb 20, 2015

Identify the invalid C expression or choose "all are valid". Assume all variables are integer and non-zero.

7.
a) a+b-0 b) c+-a%4 c) xm6-24 d) xf3r6+2
e) all are valid

8.
a) xx+yy%zz b) z%(z%z%z)) c) ha+ha+ha d) x23-20.4
e) all are valid

[Code] ......

View 10 Replies View Related

C# :: Histogram - Identify Integer In Array And Insert Symbol For Every Single One

Apr 18, 2015

I am supposed to make a histogram. I succeeded in generating the integers for the histogram. But what I want to do is instead of displaying numbers in the console, I want something like "*" displayed for every integer there is in an array. It should look something like this.

*
****
*****
********
**********
******
****
***
*

As far as I understand, in some way I need to identify the integer in the array and for every single one of them I need to insert the symbol. I don't know how to identify it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1{
class Program {
static void Main(string[] args) {
diceHistogram();

[Code] .....

View 2 Replies View Related

C :: Value Of A Polynomial In A Point

Jan 3, 2015

I don't know why this doesn't work. It doesn't return any errors, but it does the polynomial equation wrong. I tried using "^" instead of "pow" and it still does it wrong. I'm getting results like "-897123897" instead of "3". This is the code:

Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
[code]....

View 4 Replies View Related

C :: How To Get Derivative Of Polynomial

Nov 12, 2014

How to get the derivative of a polynomial.

Code:
#include "p.h"#include <stdio.h>
#include <stdlib.h>

/*----------------------------------------------*/
/* Sets all coefficients to 0 */
/*--------------------------------------------- */
void initialize(Polynomial p)

[Code] .....

View 2 Replies View Related

C++ :: Compute The Value Of A Polynomial

Mar 27, 2014

This program is supposed to find the value of a polynomial

with x being the number of terms

a[x] being the coefficients

b[x] being the exponents in each term

j being the variable

for example if

x=4

a[x]=1,2,1,5

b[x]=3,2,1,0

j=2

then the polynomial is (j*j*j)+2(j*j)+j+5

the value will be 23

however the value computed is wrong in the code below

#include <stdio.h>
#include <math.h>
int main()

[Code].....

View 4 Replies View Related

C++ :: Program That Will Calculate Minimal Polynomial?

Apr 20, 2013

I need to make a program that will calculate minimal polynomial of the nxn matrix.

View 1 Replies View Related

C++ :: Extracting Polynomial Coefficient From String

Nov 30, 2013

I want to extract polynomial coefficient out of a string recieved by input, for example if i enter 4x^3+2x^4+3 , the resulting out put be : 2 , 4 , 0 , 0 , 3

View 10 Replies View Related

C/C++ :: Simple Polynomial Derivative Calculator

Feb 27, 2014

So I'm trying to make a derivative calculator that can do simple polynomial calculations in a very specific way. If you read the cout line you'll understand rather quickly.

#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
struct variable {
char Variable,degree,constant;

[Code] ....

I get an error at line 33 and 37 saying error: request for member '_cstr' in 'constant', which is of non-class type 'char'
and the same line with 'degree' instead of constant.

View 2 Replies View Related

C/C++ :: Define Polynomial Using Linked List

Mar 18, 2014

I'm try to write a program which define a polynomial using a linked list.

1) I fill every node of the list which list is as long as the value of the max power of the polynomial.
2) I print it out the resulting polynomial.
3) I want to re-scan the poly in search for the polynomials with the same index and sum them each other for having only one element with the same index, for instance, if I enter P(x) = 1 + x + x^2 + 3*x^2 + x^3, I want to obtain:
P(x) = 1 + x + (1 + 3)*x^2 + x^3.

I called this function SeekForSameIndex().

But with this example I have 4x^2 + 4x^2 + x^3, losing the firsts members of the expression, I'm behind this problem for days and I do not understand where's the mistake.

Here my code:

#include <stdio.h>
#include <stdlib.h>
struct SPoly {
int coeff;
unsigned int index;

[Code] ....

View 1 Replies View Related

C :: Implementing And Manipulating Polynomial ADT Using Linked List

Sep 23, 2014

Implementing and manipulating a Polynomial ADT using a linked list.

So far I have:

poly_ADT.h
Code: typedef struct nodeT{
int coef;
int powr;
struct nodeT *next;
} node;

[Code]...

I need to create a function that creates the polynomial using input first.

poly *poly_create (num,...) ;return a new polynomial with num terms terms are listed in order of lowest ordered-term to highest. i.e., to initialize poly 15x^6 + -9x^4 + 3x^2 call poly_create(3, 3,2, -9,4, 15,6 );

Once I do that I need to implement various functions that can manipulate the polynomial itself but I'm having trouble just with creating the polynomial itself, how to do that using a linked list and nodes?

View 3 Replies View Related

C :: Program Doesn't Properly Compute Simple Polynomial

Feb 7, 2014

The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.

Code:

#include <stdio.h>
int main(void)
{
int x, polynomial;
}

[code]...

View 5 Replies View Related

C++ :: Polynomial Objects - Deep Copy And Operator Overloading

Feb 22, 2015

In main I instantiate two Polynomial objects -- p1 and p2:

int main() {
const int SIZE = 3;
Polynomial *p1 = new Polynomial(SIZE);
Polynomial *p2 = new Polynomial(SIZE);

//Read data into p1
std::cout << "Initialize Polynomial Coefficients (1)" << std::endl;

[Code] .....

The implementation file for Polynomial is as follows:

Polynomial::~Polynomial() {
delete [] this->m_Ptr;
this->m_Ptr = NULL;
} Polynomial::Polynomial(int size) {

[Code] .....

What works: Adding two pointers. The output is correctly produced.

The problem in particular occurs in main when p1 and p2 are attempted to be multiplied. The code attempts to release the memory upon multiplication but I receive a run-time error.

The output for the difference of the two polynomial objects is incorrect. It is displaying addresses.

View 3 Replies View Related

C++ :: Polynomial Coefficients Are Memorialized In Field Of Real Double Precision Numbers

Mar 19, 2013

I am starting to learn C++.Designing class CPolynom to work with polynomials. The polynomial coefficients are memorialized in the field of real double precision numbers. Implement the following functions:

-Constructor, which defines the order of the polynomial CPolynom(int order)
-method to add the appropriate grade Coef(int exp, duble coef)
-method of addition, subtraction, multiplication and division two polynomials
-method to add a field coefficient
-method for nala

View 1 Replies View Related

C# :: Length Cannot Be Less Than Zero

Nov 12, 2014

Exception Details: System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length

using System;
using System.Data;
using System.Configuration;

[Code]....

View 2 Replies View Related

C++ :: Using Arrays As Sources Of Data For Arrays In A Structure?

Feb 6, 2014

I define "Comwords" as a string, but apparently it takes the members as chars, then I can't set strings in a structure equal to the chars.

I see to also be having unknown problems with the ComMAL array and loading it values into another element of the same structure.

How to correct this? I was thinking of casting char elements as strings, but could find no reference in my library book regarding how to do that (lots on casting int's a doubles...)

Code:

int _tmain(int argc, _TCHAR* argv[]) {
int comm = 10;
int targ = 5;
int death;
struct AI_WORDS

[Code]....

View 2 Replies View Related

C :: Assigning Values To Arrays / Printing Arrays

Jul 1, 2014

Using a for loop, construct two 100 element arrays, x and y, such that element i of x stores the value sin(2*pi*i/100)) and the corresponding element of y stores cos((2*pi*i/100)). Print the values stored in the elements of x and y as you calculate them.

I have attempted to solve it but I'm not sure why the value 0 is only being printed, maybe I haven't assigned sin(2i/100)) and cos((2i/100)) to the arrays properly?

Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main () {

[Code] .....

View 3 Replies View Related

C++ :: Can't Get Length Of String

Nov 20, 2013

I'm trying some codes about string arrays and taking array length. But i have some problems. I can't get length of string and can't send to a function.

------------------------
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
void GetLength(string);
std::string Words[]={"table","gun","programming"};
int main()
{std::string InputWord;

[Code]...

And how can send Matrix to other function?

View 2 Replies View Related

C++ :: Can Get Length Of Integer?

Oct 3, 2013

The programming problem is supposed to take a decimal number from a user and turn it into a binary number. Here is my code:

for (int i=0; i< count; i++) {
binary[i] = decimal % 2;
decimal = decimal/2;
} cout << binary[2] << endl;

decimal is the number entered by the user.

binary [] is the char array and count is... you know how many times the for loop will turn. So my question is, how do i know the length of the number ? Any function that shows the integer length ? because its impossible to know what count is equal to. like 100 is 3.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved