Tuesday, July 9, 2019

c interview question 23

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a=2,b=6;
    printf("%d\t",funcl(a,b));
    printf("%d\n",func2(a,b));
    return 0;
}
funcl(int a, int b)
{
    int i,s=0;
    for(i=a;i<=b;i++)
    {s=s+i*i;}
return s;
}
func2(int a, int b)
{
    int s;
    if (a<b)
        s=a*a+func2(a+1,b);
    else
        s=a*a;
}


output::
90      90

No comments:

Post a Comment

python class topic video