Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 59 additions & 71 deletions Windows_System_examples/Love-Calculator/main.c
Original file line number Diff line number Diff line change
@@ -1,91 +1,79 @@
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
int main()


void enter_string(char* message, char* s, size_t s_size) {
printf("%s", message);
fgets(s, s_size, stdin);
}

int get_score(char* s)
{
int i,a2,g=0,p,a1,s2=0,b,s1=0;
char s[1000],st[1000];
printf("Enter The First Name: ");
fgets(s, sizeof(s), stdin);
for ( i = 0; s[i] != '\0'; i++);
a1=i-1;
printf("Enter The Second Name: ");
fgets(st, sizeof(st), stdin);
for ( i = 0; st[i] != '\0'; i++);
a2=i-1;
for(int j=0;j<a1;j++)
{
b=(int) s[j];

if(s[j]==' ')
char *end;
for (end = s; *end != '\0'; ++end);
--end;

if (end == s)
{
continue;
printf("wrong Input\n");
return -1;
}
else if(s[j]>='A'&&s[j]<='Z')
{
s1=s1+(b-64)*5;
}
else if(s[j]>='a'&&s[j]<='z')

int score = 0;
char c;
for(char* p = s; p != end; ++p)
{
s1=s1+(b-96)*5;
}
c = *p ^ 0x20;

if(c == ' ')
{
continue;
}
else if(c >= 'A' && c <= 'Z')
{
score += c - '@';
}
else
{
printf("wrong Input\n");
g=12;
break;
}
return -1;
}
}
return score * 5 / (end - s);
}
s1=s1/a1;

int main()
{
int p,s1,s2;
char name[1000];

for(int j=0;j<a2;j++)
{
b=(int) st[j];

if(st[j]==' ')
while(1)
{
continue;
}
do
{
enter_string("Enter The First Name: ", name, sizeof(name));
s1 = get_score(name);
} while (s1 == -1);

else if(st[j]>='A'&&st[j]<='Z')
{
s2=s2+(b-64)*5;
}
else if(st[j]>='a'&&st[j]<='z')
{
s2=s2+(b-96)*5;
}
do
{
enter_string("Enter The Second Name: ", name, sizeof(name));
s2 = get_score(name);
} while (s2 == -1);

if(s2 > s1)
{
p = (s1 * 100) / s2;
}
else
{
printf("wrong Input\n");
g=12;
break;
}

}
s2=s2/a2;
p = (s2 * 100) / s1;
}

if(g!=12)
{
if(s2>s1)
{
p=(s1*100)/s2;
}
else
{
p=(s2*100)/s1;
}
char ch='%';
printf("The love Percentage is : %d %c\n",p,ch);
}
else
{
printf("Input Error\n");
}
printf("\n pls Follow me 🌟 if you like this code 😊\n");
return main();
printf("The love Percentage is : %d %% \n",p);
printf("\n pls Follow me 🌟 if you like this code 😊\n");
}
return 0;
}


Expand Down