473,474 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

#INF00 error Dev- c++ I'm messing around with some C code using floats and I'm getti

1 New Member
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
using namespace std;

int Tridiag(int n,
float a[],
float b[],
float c[],
float d[],
float x[] )
{
float t[11];
float p[11];
float s[10];
float y[11];
int i,j;
for(i=2;i<=n;i++)
p[i]=a[i];
t[1]=b[1];
if(t[1]==0)
return 0;
s[1]=c[1]/t[1];
t[1]=d[1]/t[1];
for(i=2;i<=n-1;i++)
{t[i]=b[i]-a[i]*s[i-1];
if(t[i]==0)
return 0;
s[i]=c[i]/t[i];
y[i]=(d[i]-a[i]*y[i-1])/t[i];
}
t[n]=b[n]-a[n]*s[n-1];
if(t[n]==0)
return 0;
x[n]=(d[n]-a[n]*y[n-1])/t[n];
for(i=n-1;i>=1;i--)
x[i]=y[i]-s[i]*x[i+1];
return 1;
}
int main()
{ int n=3;
float a[]={1,1};
float b[]={2,0.5,1.5};
float c[]={-1,-1};
float d[]={1,2};
float x[3];
Tridiag(n ,a, b, c, d, x);
printf("x1= %f \n x2=%f\n x3=%f\n", x[1] ,x[2],x[3]) ;
printf("\n");
system("PAUSE");
return 0;
}
Jan 18 '15 #1
1 1709
weaknessforcats
9,208 Recognized Expert Moderator Expert
You are trying to printf an array x[3] using x[1], x[2], and x[3].

There is no x[3].

The array elements are x[0], x[1], and x[2].
Jan 18 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: lawrence | last post by:
Can someone please tell me where I can get some open source code for resizing images? I know such code has been written a million times and I don't feel like doing it again from scratch.
3
by: mike | last post by:
trying the following code to test SQL connection to MS SQL server using machine DNS name. receiving errors: undefined reference to 'SQLAllocEnv@4' undefined reference to 'SQLAllocConnect@8'...
10
by: Andrew Kidd | last post by:
I see this when I'm stepping through in the debugger ... just thought I'd ask, and I just know it's going to be one of those "Doh" moments, but it's got me foxed just now.
3
by: Joel Byrd | last post by:
I've got a 2-column tableless layout and I'm using floats to render the columns. Here are the basic style definitions for the 2 columns: #left_col { width: 59%; float: left; clear: left; }
4
by: Rafael Tejera | last post by:
I'm moving some code from my old pc. I'm using VS NET 2003 C# and MSSQL 2003. Everything is in place, but I'm receiving this error messages. thansk for you help... Here is the error...
2
by: Jared Kail | last post by:
I've never mixed managed and unmanaged C++ before, but I've done a lot of "research" out on the web. Using some examples out there, I wrote this: #using <mscorlib.dll> using namespace System; ...
2
by: parag_paul | last post by:
hi All, I find the syntax not be much intriguing in PHP . So I want to see some code existing in net. Is there any source base of php code lying around. If yes do help me -Parag
6
by: sherrygomindes | last post by:
Hi I have written a perl script using the Telnet module. I need to remotely login in from one windows XP machine to another XP machine. But i get errors which i can't figure out the reason....
0
by: Daniel Halvorse | last post by:
hi I am working on an application that manages the data in a access database. but i cant seem to get past this error. When i try to run it it says: "Syntax error in INSERT INTO statement" syntax...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.