This task is to find the number of 'For' loops present in the given cpp program.
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);
}

}

Example solution: 1
Example explanation: 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.

Problem: int t,m,n,i,j,k,xx,x1,x2,x,y,s,n0;

void init(int a[],int b[])
{ freopen("tt.in","r",stdin);
scanf("%d%d",&m,&n);
for (i=1;i<=m;i++)

scanf("%d",&a[i]);
for (i=1;i<=n;i++)

scanf("%d",&b[i]);

}

void output(int a[],int k)
{
int i;
freopen("tt.out","w",stdout);
for(i=1;i<=k;i++) if (i==1) printf("%d",a[i]); else printf(" %d",a[i]);
}
void proce(int n,int b)
{
int i;
if (n==1) s++;
else
for (i=b;i<=n0;i++)
if (!(n%i)) proce(n/i,i);

}

int main()
{
//freopen("tt.in","r",stdin);
//freopen("tt.out","w",stdout);
scanf("%d",&n);

for (i=1; i<=n;i++)
{
scanf("%d",&x);
s=0;
n0=x;
proce(x,2);
printf("%d
",s);
}

return 0;
}
Solution: 5