Monday, May 16, 2011

Love Calculator

/*
Created By Rana Hamid
http://uvacode.blogspot.com/
+8801717623876
http://facebook.com/ranahamid07/
*/

//10424
#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>

int sum(int n)
{
    int sum=0;
    while(n>0)
    {
    sum=sum+n%10;
    n=n/10;
    }
    return sum;
}

int main()
{
   char name1[256],name2[256];
   int i,j,k,sum1,sum2,len1,len2;
   float ratio=0;
   int sum22=0;
//clrscr();
   while((sum22==0)==1)
   {

//   textcolor(2) ;

//textbackground(4);
   printf("\n");
   printf("\nEnter your name_____No for exit\n");
   gets(name1);
    //     printf("\n");
//    textcolor(3) ;
         if(
         (name1[0]=='n' && name1[1]=='o')||

         (name1[0]=='N' && name1[1]=='o')||

         (name1[0]=='n' && name1[1]=='O')||
         (name1[0]=='N' && name1[1]=='O')
         )
         break;
//textbackground(5);
    printf("\n");
    printf("\nEnter your partner name\n");
   gets(name2);
  // printf("\n");

          if(
         (name1[0]=='n' && name1[1]=='o')||

         (name1[0]=='N' && name1[1]=='o')||

         (name1[0]=='n' && name1[1]=='O')||
         (name1[0]=='N' && name1[1]=='O')
         )
         break;

    sum1=0,sum2=0;
    len1=strlen(name1);
    len2=strlen(name2);
    for(i=0;i<len1;i++)
      {
      if( (name1[i]>='a') &&(name1[i]<='z') )
      sum1=sum1+(name1[i]-96);
      else if ( (name1[i]>='A') &&(name1[i]<='Z') )
      sum1=sum1+(name1[i]-64);
      }
   //
 // printf("sum1 is %d",sum1);
    for(i=0;i<len2;i++)
      {
      if( (name2[i]>='a') &&(name2[i]<='z') )
      sum2=sum2+(name2[i]-96);
      else if ( (name2[i]>='A') &&(name2[i]<='Z') )
      sum2=sum2+(name2[i]-64);
      }
  //   printf("\nsum2 is %d\n",sum2);

      i=0;
   while(sum1>9)
    {
    sum1=sum(sum1);
    }
    //
  // printf("sum00001 is %d",sum1);

        i=0;
   while(sum2>9)
    {
    sum2=sum(sum2);
    }
    //
  // printf("\nsum00002 is %d",sum2);
   ratio=((float)sum1/sum2)*100;

//textbackground(0);
     printf("_____________________________________\n");
      printf("\n");
//      textcolor(6) ;

      printf("\n_____________________________________");
         printf("\n");
      //if(  (name1=="RANA HAMID") ||(name1=="RANA")||(name1=="rana")||(name1=="rana hamid")||(name2=="RANA HAMID") ||(name2=="RANA")||(name2=="rana")||(name2=="rana hamid"))
  // if(name1[26]=="RANA")
//Your Name so that the soft can display 100% on your name.......
if(

(name1[0]=='R' && name1[1]=='A' && name1[2]=='N' && name1[3]=='A')||
(name1[0]=='r' && name1[1]=='a' && name1[2]=='n' && name1[3]=='a' )||
(name1[0]=='R' && name1[1]=='A' && name1[2]=='N' && name1[3]=='A' &&
name1[4]==' ' && name1[5]=='H' && name1[6]=='A' && name1[7]=='M' &&
name1[8]=='I' && name1[9]=='D' )

||

(name2[0]=='R' && name2[1]=='A' && name2[2]=='N' && name2[3]=='A')||
(name2[0]=='r' && name2[1]=='a' && name2[2]=='n' && name2[3]=='a' )||
(name2[0]=='R' && name2[1]=='A' && name2[2]=='N' && name2[3]=='A' &&
name2[4]==' ' && name2[5]=='H' && name2[6]=='A' && name2[7]=='M' &&
name2[8]=='I' && name2[9]=='D' )

  )
{
//textcolor(4) ;
//textbackground(2);
float ra=100;
    printf("\nYour love is  %.2f %c\n",ra,'%');
 }

else if(ratio<=100)
{
//textcolor(4) ;
//textbackground(2);

    printf("\nYour love is  %.2f %c\n",ratio,'%');
 }
    else if (ratio>100)
    {
         ratio=((float)sum2/sum1)*100;
//         textcolor(4) ;

//textbackground(2);
         printf("\nYour love is  %.2f %c\n",ratio,'%');
     }
     }
     return 0;
}