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.

Page Contents

## Algorithm for love calculator

1. Take input girl and boy name
2. Calculate sum1 = each letter of a boy name
3. Calculate sum2 = each letter of a girl name
4. Percentage = Each digits in sum1 + Each digits in sum2 + 40
5. 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

{

fflush(stdin);

gets(your_nm);

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;