Custom Search

Thursday, March 15, 2007

C - Review II 4 ,5

4. main() {

int reset(int );
int i=5;
reset(i);
}
int reset(int n){
if(n==0)
return 0;
else
printf(“%d”, n);
reset(n--);
}
Output: infinite recursion. It continuously prints 5 and after some time stack overflow occurs.

5.

main(){

register int i;

int *ptr;

ptr = &i;

i=10;

printf(“%d”,*ptr);

}

Output: Compilation error. We cannot refer the address of a register variable

No comments: