#include<iostream.h> #include<iostream.h>
#include<conio.h>
#include<math.h>
void display()
int main()
{
int a=9;
int b=10;
clrscr();
cout<<display(a,b)<<"\n";
return 0;
getch();
}
void display(int A[] [],int m, int n)
{
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
cout<<" "<<A[i][j];
cout<<"\n";
}
i have listed my program to call a function above but it is showing an error as below in line 5 called ' Declaration syntax error'
kindly help me solve this
10 1984 Meetee 931
Recognized Expert Moderator Contributor
#include<iostream.h> #include<iostream.h>
#include<conio.h>
#include<math.h>
void display()
int main()
{
int a=9;
int b=10;
clrscr();
cout<<display(a,b)<<"\n";
return 0;
getch();
}
void display(int A[] [],int m, int n)
{
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
cout<<" "<<A[i][j];
cout<<"\n";
}
i have listed my program to call a function above but it is showing an error as below in line 5 called ' Declaration syntax error'
kindly help me solve this
You have define and declare same function with different parameters!!! I am pointing to void display()
Regards
Yeah, I'm just starting CIS247 and went through functions briefly but, he is right on the paramaters. When you declare your function within the () you need to list the same paramaters as you use below in your code using the & before repeated use declarations.
functions (one, &two, three, four, &five, six)
int main ()
...
...
...
..now you call it
functions (here you need to call out the parameters the same as above)
(one, two, three, four, five, six)
Your code seems pretty sophisticated to not know how to call a function. Hope you get it. Joe
void display (int, &double, &double, &char, int, double)
when calling
void display (int, double, double, char, int, double)
or close to that--later
void display (int, &double, &double, &char, int, double)
when calling
void display (int, double, double, char, int, double)
or close to that--later
hi Joe, thanx for the help i made the changes but it shows 2 errors now.
1. size of the type is unknown or zero and 2. declaration is expected
i m pasting the program again with my changes
#include<iostream.h> #include<iostream.h>
#include<conio.h>
#include<math.h>
void display(int A[] [],int m, int n,)
int main()
{
int a=9;
int b=10;
clrscr();
cout<<display(a,b)<<"\n";
return 0;
getch();
}
void display(int A[] [],int m, int n)
{
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
cout<<" "<<A[i][j];
cout<<"\n";
}
kindly b patient as i have just started learning C++ and am doing it on my own with aid from you guys and this site
Meetee 931
Recognized Expert Moderator Contributor
hi Joe, thanx for the help i made the changes but it shows 2 errors now.
1. size of the type is unknown or zero and 2. declaration is expected
i m pasting the program again with my changes
#include<iostream.h> #include<iostream.h>
#include<conio.h>
#include<math.h>
void display(int A[] [],int m, int n,)
int main()
{
int a=9;
int b=10;
clrscr();
cout<<display(a,b)<<"\n";
return 0;
getch();
}
void display(int A[] [],int m, int n)
{
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
cout<<" "<<A[i][j];
cout<<"\n";
}
kindly b patient as i have just started learning C++ and am doing it on my own with aid from you guys and this site
Hi magnacarta,
Again you check your code. You are calling display with two parameters and function is defined/declared with 3 parameters. You can define array locally in display function as you are just printing the value locally.
Regards
PS. Kindly put code tags around code
Just for comparison: -
#include<iostream> // removed trailing ".h"
-
#include<conio.h> // careful, this is a Windows only library!!!
-
#include<cmath> // changed from "math.h" to "cmath"
-
-
// old declaration: notice there is a comma after 'n'
-
// and no semicolon at the end of the prototype
-
// void display(int A[] [],int m, int n,)
-
-
// new function prototype
-
void display (int a, int b);
-
-
int main()
-
{
-
int a=9;
-
int b=10;
-
-
// ...stuff before function call...
-
cout<<display(a,b)<<"\n";
-
// ... stuff after function call...
-
}
-
-
// old declaration
-
//void display(int A[] [],int m, int n)
-
void display (int a, int b)
-
{
-
// ...stuff in function...
-
}
-
Or if you still need the array, then the function call is the part of the code that needs to be edited. i.e., you'd need to add the array to be passed to the function.
#include<iostream.h> #include<iostream.h>
#include<conio.h>
#include<math.h>
void display()
int main()
{
int a=9;
int b=10;
clrscr();
cout<<display(a,b)<<"\n";
return 0;
getch();
}
void display(int A[] [],int m, int n)
{
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
cout<<" "<<A[i][j];
cout<<"\n";
}
i have listed my program to call a function above but it is showing an error as below in line 5 called ' Declaration syntax error'
kindly help me solve this
The error in the program is that you are not passing the 3 arguments that you are making use of in the function. Change the display function to
void display(int m, int n)
{int A[3] [3];
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
printf("%d",A[i][j]);
printf("\n");
}
and your program should work
The error in the program is that you are not passing the 3 arguments that you are making use of in the function. Change the display function to
void display(int m, int n)
{int A[3] [3];
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
printf("%d",A[i][j]);
printf("\n");
}
and your program should work
i made the changes as to my understanding but not there is an error 'Declaration syntax error' in line 5. could some one kindly make this program error free put it here. sorry but thanx
void display(int m, int n)
{int A[3] [3];
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
printf("%d",A[i][j]);
printf("\n");
}
You have nested for loops but no braces: -
for (etc...)
-
{
-
for (etc...)
-
{
-
-
}
-
}
-
Also, the array is a local variable so there is no way to get values in the array from main(). Did you mean to do that??? Or did you mean to create the array in main() and then call the function to display the array?? I thinkl you still have a logic problem.
hi Joe, thanx for the help i made the changes but it shows 2 errors now.
1. size of the type is unknown or zero and 2. declaration is expected
i m pasting the program again with my changes
#include<iostream.h> #include<iostream.h>
#include<conio.h>
#include<math.h>
void display(int A[] [],int m, int n,)
int main()
{
int a=9;
int b=10;
clrscr();
cout<<display(a,b)<<"\n";
return 0;
getch();
}
void display(int A[] [],int m, int n)
{
int i,j;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
cout<<" "<<A[i][j];
cout<<"\n";
}
kindly b patient as i have just started learning C++ and am doing it on my own with aid from you guys and this site
Magnacarta, so far in every one of your posts, you also forgot the ; at the end of your prototype in line 5:
void display(int A[] [],int m, int n,)
should be
void display(int A[] [],int m, int n,);
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dover |
last post by:
/*Copy the line a token at a time into the output*/
copy(istream_iterator<string>(iss),
istream_iterator<string>(),
ostream_iterator<string>(oss, " "));
What's the meaning of this statement?...
|
by: Phil Reardon |
last post by:
Ive been away from programming for a few years and am having difficulty
accessing a function from a math/engineering library that I want to use .
I thought that double foo(double); inserted in the...
|
by: feminine.aura |
last post by:
I have to read a file containing integers into a vector. I could do
something like this:
ifstream data("file.dat");
istream_iterator<intbegin(data);
istream_iterator<intend;...
|
by: nospam_timur |
last post by:
Let's say I have two files, myfile.h and myfile.c:
myfile.h:
int myfunction(int x);
myfile.c:
#include "myfile.h"
|
by: INeedADip |
last post by:
What is the difference between:
function setupGrid( param ){......}
and
setupGrid = function( param ){......}
Are there any advantages to doing one over the other?
| |
by: wtu |
last post by:
function Declaration&Definition
--------------------------------------------------------------------------------
" Geroty (const vector<Point3D>& poly, const Plane& Tr)"
As i'm c++ beginner...
|
by: Lawrence Spector |
last post by:
Base base;
BaseWrap& baseWrap(reinterpret_cast<BaseWrap&>(base));
boost::python::object obj(boost::shared_ptr<BaseWrap>(&baseWrap)); //
Compile error
Results in this error:
...
|
by: florian.loitsch |
last post by:
I wondered what should be the result of the following code:
===
function f() {
x = false;
function x() {};
alert(x);
}
===
According to Ecmascript-spec we have the following rules:
10.1.3:...
|
by: Ravishankar S |
last post by:
Dear C Experts,
While prepating a content for a C course,I made section on function
prototypes.
Could you kindly provide me your comments on its correctness. Thank you !
Q12: What is the...
|
by: Sri Harsha Dandibhotla |
last post by:
Hello all.
I recently came across a function declaration as :
char(*(*x()))();
This was not in some code but it was in a C questions thread on some
group.
I tried to decipher what it returns but...
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |