1) can anyone please help me to understand why this code just show 36 ? my analysis it should be :
1
4
9
16
25
Code:
#include<stdio.h>
int funct1(int count);
void main ()
{
int a,count;
for(count=1;count<=5;++ count);
{
a= funct1(count);
printf("a=%d\n",a);
}
}
int funct1(int x)
{
int y;
y=x*x;
return y ;
}
// 1 4 9 16 25
2) its difficult for me to understand argument exchange in the transfer function . a detail explanation will be really helpfull. thank you all for reading me.
Code:
/* The TOWERS OF HANOI- solver using recursion*/
#include<stdio.h>
void transfer (int n, char from, char to , char temp);
void main()
{
int n;
printf(" Welcome to the TOWERS OF HANOI\n\n");
printf("How many disks?");
scanf("%d", &n);
printf("\n");
transfer (n,'L','R','C');
}
void transfer ( int n, char from, char to, char temp)
{
if(n>0)
{
transfer(n-1,from,temp,to);
printf("Move disk %d from %c to %c\n",n, from,to);
transfer(n-1, temp,to,from);
}
return;
}