#include<iostream.h>
void main()
{
void prn(int a);
void prn(int a,int b);
int x,y;
cout<<”\n enter a number”;
cin>>x;
prn(x);
cout<<”\n enter two numbers”;
cin>>x>>y;
prn(x,y);
getch();
}

void prn(int a)
{
cout<<a;
return ;
}

void  prn(int a,int b)
{
cout<<a<<b;
return ;
}

Are you asking a question, or just showing off your substandard programming abilities?

Member Avatar for iamthwee

This should go in the code snippet section surely [Tongue in cheek]

Are you asking a question, or just showing off your substandard programming abilities?

I can do the code which was posted correctly when the function definitions are globally defined.But i cannot work the same when not globally defined.I want to know why is it so?An example for such a code is posted.pls see it and reply why there is a compilation error.

That's because ur function prototypes ARE in main()... And try using int main() instead of void()...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.