Hi All,

Please see the code below.

This is the problem.
Code:
#include<stdio.h>

void change()
{
/*Write something in this function so that the
output of printf in main function should give 5  .
Do not change the main function */

 
}

int main()
{

	int i=5;
	change();
	i=10;
	printf("%d",i);
	getch();
	return 0;
}
The solution of the problem is given below.

Code:
#include<stdio.h>

void change()
{
/*Write something in this function so that the
output of printf in main function should give 5  .
Do not change the main function */

	#define printf(fmt,x) printf ( "%d\n", 5 ) 

 
}

int main()
{

	int i=5;
	change();
	i=10;
	printf("%d",i);
	getch();
	return 0;
}
Now my Question is how does it Work ? since macro is define in the function i.e. it becomes local to function then how the out put of printf has changed?

Regards,
x8086