By | 03.12.2016

# C program to design love calculator and calculate love percentage

Write a C program to design love calculator and calculate love percentage.This program will read you and your partner’s name and behalf on entered names program will calculate your love percentage.

Since there is no such kind of logic to calculate the program, we made this program for fun only. This is a small game to pass your time by calculating love percentage between you and your partner.

And off course you can also calculate the love percentage with others girl to see how much you love will success with your secrete partner. So enjoy the game.

Below is the source code of the C program to design love calculator which is successfully compiled and run on the windows system.The Output of the program is shown below.

## SOURCE : :

```#include <stdio.h>
#include <string.h>
#include <ctype.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 yName[40], pName[40];
int sum, sum1, i, choice;
float perc=0;

do
{
printf("\n============================================\n");

printf("Enter your name: ");
fflush(stdin);
gets(yName);

printf("Enter your partner's name: ");
fflush(stdin);
gets(pName);

printf("\nPlease wait Calculating.....\n");

sum=0;
for(i=0;i<(strlen(yName));i++)
{
sum+=tolower(yName[i]);
}

sum1=0;
for(i=0;i<(strlen(yName));i++)
{
sum1+=tolower(pName[i]);
}

printf("\nCalculation completed!!!!!\n");
perc=(sumOfDigits(sum)+sumOfDigits(sum1))+40;
if(perc>100) perc=100;

printf("\nYour love percentage is: %.02f\n\n",perc);

printf("Want to calculate with some one else (0 to exit, 1 to continue) ???: ");
scanf("%d",&choice);

}while(choice!=0);

return 0;
}```

Also Read : : Write a C program to design flying characters Screen Saver

## OUTPUT : :

```============================================
Enter your name: Codez
Enter your partner's name: Club

Please wait Calculating.....

Calculation completed!!!!!

Your love percentage is: 59.00

Want to calculate with some one else (0 to exit, 1 to continue) ???: 1

============================================
Enter your name: John Smith
Enter your partner's name: Shreen

Please wait Calculating.....

Calculation completed!!!!!

Your love percentage is: 59.00

Want to calculate with some one else (0 to exit, 1 to continue) ???: 1

============================================
Enter your name: Jackman
Enter your partner's name: Katty

Please wait Calculating.....

Calculation completed!!!!!

Your love percentage is: 71.00

Want to calculate with some one else (0 to exit, 1 to continue) ???: 0```
5 1 vote
Article Rating
Category: Advance Programs C Programming Tags:

## About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of

0 Comments
Inline Feedbacks
View all comments