**C Program to implement love calculator:** Love calculator program is only for entertainment.

For implementing such type of program we can use any logic such program has no predefined logic. It’s only implemented for fun.

**The logic for love calculator**

First, we take the name of girl and boy (partners) to calculate their percentage of love.

We calculate a sum of the value of each letter in the girl name by using its ASCII values and store sum in sum1.

Same for a boy name, we calculate a sum of a value of each letter in boy name by using its ASCII values and store in sum2.

Now, we add each digit in sum1 and sum2 and sum with 40 to total.

This resultant sum we can consider as the percentage of love between partners.

## Algorithm for love calculator

- Take input girl and boy name
- Calculate sum1 = each letter of a boy name
- Calculate sum2 = each letter of a girl name
- Percentage = Each digits in sum1 + Each digits in sum2 + 40
- Print Percentage

## C Program to implement love calculator

#include <string.h> #include <ctype.h> #include <stdio.h> //function will return sum of all digits int sumOfDigits(int num) { int sum=0; while(num>0) { sum+=(num%10); num/=10; } return sum; } int main() { char your_nm[40], prtnr_nm[40]; int sum, sum1, i, choice; float perc=0; do { printf("Enter your name: "); fflush(stdin); gets(your_nm); printf("Enter your partner's name: "); fflush(stdin); gets(prtnr_nm); sum=0; for(i=0;i<(strlen(your_nm));i++) { sum+=tolower(your_nm[i]); } sum1=0; for(i=0;i<(strlen(your_nm));i++) { sum1+=tolower(prtnr_nm[i]); } perc=(sumOfDigits(sum)+sumOfDigits(sum1))+40; if(perc>100) perc=100; printf("Your love percentage is: %.02f\n\n",perc); printf("Want to calculate again (0 to exit, 1 to continue) ???: "); scanf("%d",&choice); }while(choice!=0); return 0; }

**Output :**