function parameter passed as copy

why the function value not printed

Page 1 of 1

2 Replies - 393 Views - Last Post: 11 April 2010 - 10:26 PM Rate Topic: -----

#1 Guest_isha_03*


Reputation:

function parameter passed as copy

Posted 11 April 2010 - 10:21 PM

Hi
I am passing the copy of the parameter , but when the function is called from main it is not executing plz help.

#include<stdio.h>
int main()
{
int Parameter1;
Parameter1 = 5;
void subroutine1(int Parameter1);
printf("hello");
printf("%d \n",Parameter1);

}
void subroutine1(int Parameter1)
{
printf("%d \n",Parameter1);
printf("hell2o");
}

Is This A Good Question/Topic? 0

Replies To: function parameter passed as copy

#2 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1072
  • View blog
  • Posts: 4,532
  • Joined: 09-June 09

Re: function parameter passed as copy

Posted 11 April 2010 - 10:24 PM

put the prototype at the top above main()
#include<stdio.h>

void subroutine1(int Parameter1);
int main()
{
	int Parameter1;
	Parameter1 = 5;
	subroutine1(parameter1);

	printf("hello");
	printf("%d \n",Parameter1);
	return 0;

}
void subroutine1(int Parameter1)
{
	printf("%d \n",Parameter1);
	printf("hell2o");
} 


Was This Post Helpful? 0
  • +
  • -

#3 Skaggles  Icon User is offline

  • THE PEN IS MIGHTIER
  • member icon





Reputation: 251
  • View blog
  • Posts: 640
  • Joined: 01-March 09

Re: function parameter passed as copy

Posted 11 April 2010 - 10:26 PM

Relating to what said, you can't declare a function within another function like you have here:

int main()
{
...
void subroutine1(int Parameter1);
...
}


This post has been edited by Skaggles: 11 April 2010 - 10:26 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1