Function not showing any output
Dear friends
Can some one tell me why am I not able to print the simple output in the single function defined in the code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<stdlib.h>
int i, j;
const int grid=5;
double u_star[grid][grid], v_star[grid][grid];
double u_TDMA(double x[grid][grid],double y[grid][grid]); //Function Declaration
using namespace std;
int main()
{
for (i=0; i<grid; i++)
{
for(j=0; j<grid; j++)
{
u_star[i][j]=0;
v_star[i][j]=0;
}
}
double u_TDMA(double u_star[grid][grid],double v_star[grid][grid]); //Function Call
return 0;
}
double u_TDMA(double x[grid][grid],double y[grid][grid]) //Function Definition
{
for (i=0; i<grid; i++)
{
for(j=0; j<grid; j++)
{
cout<<u_star[i][j]<<"\t"<<v_star[i][j];
}
}
}
|
What you are calling a "function call" is not a function call. It's just another function prototype.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
using namespace std;
const int Size = 5;
double u_TDMA(double x[][Size], double y[][Size]);
int main()
{
double u_star[Size][Size], v_star[Size][Size];
for (int i = 0; i < Size; i++)
{
for (int j = 0; j < Size; j++)
{
u_star[i][j] = 0.0;
v_star[i][j] = 0.0;
}
}
u_TDMA(u_star, v_star);
}
double u_TDMA(double x[][Size], double y[][Size])
{
for (int i = 0; i < Size; i++)
{
for (int j = 0; j < Size; j++)
{
cout << x[i][j] << '\t' << y[i][j] << '\n';
}
}
}
|
@dutch
Thanks
Topic archived. No new replies allowed.