I have to calculate the cosine similarity score between two pieces of code . How can I calculate it or which tool is used for this purpose?

The example of piece of code is given as follow.

void sumProd1A(int n) {
    double sum = 0.0; //C1
    double prod = 1.0;
    int i;
    for (i = 1; i <= n; i++)
        sum = sum + i;
        prod = prod * i;
        foo2(sum, prod);
void main()
    printf("\nsumProd1A_Cordy: %lf ");

  • OT: regarding void main() There are only two valid signatures for main() they are: int main( void ) and int main( int argc, char *argv[] ) – user3629249 Jul 21 '19 at 14:05
  • The usual method of calculating a cosine is to #include <math.h> then call the function: cos() however, how to calculate cosine gives the details – user3629249 Jul 21 '19 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.