Love and Friendship calculator using C/C++

Love and Friendship calculator is a small C or C++ application which implements a school-time logic. When we are in school time we play with our names and calculate some percentage. I also implemented one of them logic to calculate Love and friendship.

Love and Friendship calculator

The Logic which i have implemented is as follows.

Logic
Logic Behind It
  • Two names n1 and n2 are taken from the user. And one choice for friendship or love calculation.
  • If  user choose friendship then we make a string n1+ friend + n2.
  • If user choose love then we make a string n1 + love + n2.
  • Then we start manipulation over the concatenated string from left to right.
  • We count occurrence of each character (except space) until all characters are traversed and keep that count of each character in an array.
  • Now we have an array containing count of each character. now we perform operation on this array.
  • we start adding first element of array with last element of array, second element with second last element of the array and so on.
  • Keep continue the above step until we get array with only two elements.
  • Now we have percentage. if percentage is higher then 100% we manipulate it until we get percentage less than  or equal to 100%.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.