Wednesday 23 January 2008

Function in c has parameter but not returning any value

void swap(int,int);void main(){int a=10,b=15;clrscr();printf("Befor swap a=%d ,b=%d",a,b);swap(a,b);printf("\nAfter swap a=%d ,b=%d",a,b);getch();}void swap(int a,int b){int c;c=a;a=b;b=c;}Output:Before swap a=10,b=15After swap a=10,b=20Explanation: a and b are auto variable (default storage class is auto) .Here its scope is only within main function.After the main function both a and b will

No comments:

Post a Comment