0% found this document useful (0 votes)
33 views4 pages

Flames Program Question

The document provides instructions for an online lab test on writing a C program to determine the relationship between two names using the FLAMES algorithm. It includes: - An example of using FLAMES to determine the relation between two names is "enemies". - Function prototypes for string handling functions needed to complete the program. - Input/output formats specifying the program should take two names as input and output the relation between the names according to FLAMES, displaying the intermediate FLAMES states.

Uploaded by

Kaushik Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

Flames Program Question

The document provides instructions for an online lab test on writing a C program to determine the relationship between two names using the FLAMES algorithm. It includes: - An example of using FLAMES to determine the relation between two names is "enemies". - Function prototypes for string handling functions needed to complete the program. - Input/output formats specifying the program should take two names as input and output the relation between the names according to FLAMES, displaying the intermediate FLAMES states.

Uploaded by

Kaushik Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

BIRLA INSTITUTE OF TECHNOLOGY OF SCIENCE - PILANI

K.K. BIRLA GOA CAMPUS

Second Semester 2015 - 2016


CS F111 : Computer Programming
Online Lab Test (15 April 2016) - Batch : 3

Time: 90 minutes

Max. Marks: 45 (15%)

Problem:
In school days, we used to play a game called FLAMES (F: Friend, L: Love, A: Attraction, M:
Marriage, E: Enemy, S: Sibling); which finds the relation between two names. Write a C program
that finds the relation between two names using the algorithm of FLAMES.
PS: Do not use string.h library.
[Disclaimer: Examples or names in this problem statement are unintentional. Any resemblance
in the real world is a mere coincidence.]
An example: Lets check the relation between Abhishek and Aishwarya.
Remove the common characters (case insensitive) from both the names. So, in the above problem
the characters A, i, s and h are common. (Remember there are three a in second name. But only
one a in first name and hence only once occurrence is common.) Now, the remaining number of
characters in both the names is 4 + 5 = 9; which is the number of iterations required for eliminating
a letter from FLAMES.
Now, you have to check the number 9 with FLAMES as explained below.
State 0: F L A M E S
Run/Count through FLAMES with number 9 like, F(1) L(2) A(3) M(4) E(5) S(6) F(7) L(8) A(9)
M E S. So, 9 end at A. Now delete A from FLAMES. Hence, remaining letters are FLMES.

State 1: F L M E S
Now, you have to start from M (just after where you had ended last time). So, M(1) E(2) S(3)
F(4) L(5) M(6) E(7) S(8) F(9) L E S. Delete F from FLMES. Hence, remaining letters are LMES.

CS F111 : Computer Programming

State 2: L M E S
L(1) M(2) E(3) S(4) L(5) M(6) E(7) S(8) L(9) M E S: Delete L. Remaining MES.

State 3: M E S
M(1) E(2) S(3) M(4) E(5) S(6) M(7) E(8) S(9) M E S: Delete S. Remaining ME.

State 4: M E
M(1) E(2) M(3) E(4) M(5) E(6) M(7) E(8) M(9) E: Delete M. Remaining E.

State 5: E

The remaining character E gives the relation between the two persons: Abhishek and Aishwarya
are ENEMIES.

Page 2 of 4

CS F111 : Computer Programming

Function Prototypes
Function to find the length of a string.
int StrLength ( char str []) ;

Function to shift characters of a string to left indices.


void shiftLeft ( char str [] , int pos ) ;

Ex. If str contains aaaakbaa and pos is 4. Then shiftLeft function modifies the str to aaaabaa.
Function to rearrange of a string.
void rearrange ( char str [] , int index ) ;

Ex. If str contains abcdef and index is 3. Then rearrange function rearranges the string str
to defabc.
Function to display a list of common characters and hence find the number of iterations required
(and returns it).
int findDiff ( char str1 [] , char str2 []) ;

Ex. If str1 is abcdab and str2 is abxymnd, findDiff function displays the following:
Common characters: a, b, d
Number of iterations required: 7

Input/Output Formats
Input
Names of two persons (no space or special characters).

Output
The program should display output as given in Sample I/O.
Final result need to be in the format: Name#1 and Name#2 are RELATION. (RELATION
can be obtained from FLAMES.)
Your program must display the intermediate results of FLAMES as well, i.e. the character deleted
in each step and the remaining characters.

Sample I/O:
Testcase 1:
Input
Enter Name#1: Abhishek
Enter Name#2: Aishwarya

Page 3 of 4

CS F111 : Computer Programming


Output
Length of Name#1: 8
Length of Name#2: 9
Common characters: a, h, i, s
Number of iterations required: 9
Deleted:
Deleted:
Deleted:
Deleted:
Deleted:

A, Remaining: mesfl
F, Remaining: lmes
l, Remaining: mes
s, Remaining: me
m, Remaining: e

Abhishek and Aishwarya are enemies.

Page 4 of 4

You might also like