Teacher: This task is to find the number of 'For' loops present in the given cpp program.
Teacher: Now, understand the problem? If you are still confused, see the following example:
main()
{
      float a[4];
      float k;
      float c;
      int i;
      for(i=0;i<4;i++)
      {
                      scanf("%f",&a[i]);
      }
      scanf("%f",&c);
      c=2*3.1415926*c/360;
      k=(a[0]+a[1]+a[2]+a[3])/2;
      double s,sq;
      sq=(k-a[0])*(k-a[1])*(k-a[2])*(k-a[3]) - a[0]*a[1]*a[2]*a[3]*(double)cos(c/2)*(double)cos(c/2);
    
      if(sq<0)
      printf("Invalid input");
      else
      {
          s=sqrt(sq);
          printf("%.4f",s);
      }
    
}

Solution: 1
Reason: The number of 'for' loops in the code is given by the number of 'for' string present in the code. Since we can find the exact number of for loops, this is a good example.

Now, solve this instance: int f(int,int);
int main()
{
	int n,i,a,b[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		b[i]=f(a,2);
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",b[i]);
	}
	return 0;
}
int f(int x,int y)
{
	int j,sum=1;
	if(x<y)
		sum=0;
	else
	{
		for(j=y;j<x;j++)
		{
			if(x%j==0)
				sum=sum+f(x/j,j);
		}
	}
	return sum;
}

Student:
3