Make Love Calculator using C Program; Easy Code for Beginners

This C program asks the user to enter his/her and his/her partner’s name. Then the program will give a random percentage.

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

man in black long sleeved shirt and woman in black dress
Photo by Jasmine Carter on Pexels.com

We have only used the least number of lines in this code and only used basic and necessary C program syntax. So that a beginner can also understand this code easily.

Code 1: Love Calculator using C Program

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

int main(){
    srand(time(NULL));
    int love = rand()%100 + 1;
    char n1[30], n2[30];
    printf("Welcome to Love Calculator\n\n");
    printf("Enter Your Name: ");
    gets(n1);
    printf("Enter Your Crush Name: ");
    gets(n2);
    printf("%s Loves %d Percent with %s", n1,love,n2);
    return 0;
}

Output:

Welcome to Love Calculator

Enter Your Name: Kulbhushan Kundalwal
Enter Your Crush Name: Sunny Khalifa
Kulbhushan Kundalwal Loves 99 Percent with Sunny Khalifa

Code 2: Love Calculator using C Program

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

int main(){
    srand(time(NULL));
    int i, love = rand()%100 + 1;
    char n1[30], n2[30];

    printf("\nWelcome to Love Calculator\n    Made by Kulbhushan\n\n");
    do{
        printf("Enter Your Name: ");
        fflush(stdin);
        gets(n1);
        printf("Enter Your Crush Name: ");
        fflush(stdin);
        gets(n2);
        printf("\n%s Loves %d Percent with %s", n1,love,n2);
        printf("\n\nHave a Happy Life!!\n\n");
        printf("Enter '0' to exit or '1' to continue...\n");
        scanf("%d", &i);
    }while(i==1);
    return 0;
}

Output:

Welcome to Love Calculator
    Made by Kulbhushan

Enter Your Name: Kulbhushan Kundalwal
Enter Your Crush Name: Mia Leone

Kulbhushan Kundalwal Loves 96 Percent with Mia Leone

Have a Happy Life!!

Enter '0' to exit or '1' to continue...

So, this was the simple C program to design a love calculator. It is a fun program to exercise your basic C program concepts.

You can watch the below video for understanding this code:

Leave a Reply