Professional Documents
Culture Documents
On
SUBMITTED BY:
I.D NUMBER NAME
2100031655 M. Suvarna
T. Ganesan
ASSISTANT PROFESSOR
KL UNIVERSITY
Green fields, Vaddeswaram – 522 502
Guntur Dt., AP, India.
DEPARTMENT OF BASIC ENGINEERING SCIENCES
CERTIFICATE
I express the sincere gratitude to our director Dr. A Jagadeesh for his administration
towards our academic growth.
I express sincere gratitude to our Coordinator and HOD-BES Dr. D.Haritha for her
leadership and constant motivation provided in successful completion of our academic
semester. I record it as my privilege to deeply thank for providing us the efficient faculty and
facilities to make our ideas into reality.
I express my sincere thanks to our project supervisor T. Ganesan for his/her novel
association of ideas, encouragement, appreciation and intellectual zeal which motivated us to
venture this project successfully.
Name: M. Suvarna
Peter travels from A to B in a train there are different colored flags ordered between A to B
here peter has two waking points between A to B.
So, in this, there are three lines in input the first line contains a non-empty string where the
characters must not exceed 10*5 the strings contain lower case Latin letters (flag colors from
A to B i.e., forward B to A i.e., backward)
The second line of the input contains the sequence written by peter at 1st period of
wakefulness. The third line of the input contains the sequence written by peter at 2nd period
of wakefulness.
A to B- forward
B to A- backward
A to B and B to A- both
No sequence -fantasy
INDEX
1. Introduction
4. Future Implementation
6. Class Diagram
7. Implementation
8. Outputs/ScreenShots
9. Conclusion
INTRODUCTION
STRING :
The character data type allows to store a single character only but to store more no of characters
like name of the person, city where he lives were done by using an array of characters is called string
A string is like a sentence with no of words, separated by space hence each and every string is
ended with a string terminator represented by “\0”
DECLARATION OF A STRING:
LOOPS:
When a block of code needs to be executed several number of times in general statements are
executed sequentially the first statement in a function is executed first, followed by the second, and
so on.
A loop statement allows us to execute or group of statements multiple times given below is the
general form of a loop statement in most of the programming languages.
Loop controls statements change execution from its normal sequence. when execution leaves a
scope, all automatic objects that created in that scope are destroyed.
FOR LOOP
Executes a sequence of statements multiple times and abbreviates the code that manages the loop
variable.
A for loop statement is available in most imperative programming languages .Even ignoring minor
differences in syntax there are many differences in how these statements work and the level of
expressiveness they support .Generally ,for loops fall into one of the following categories.
7The initialization declares any variables required . The type of a variable should be same if you are
using multiple variables in initialization part. The condition checks a condition, and quits the loop if
false. The after though is performed exactly once every time the loop ends and then repeats
AIM
Peter likes to travel by train. He likes it so much that on the train he falls asleep.
Once in summer, Peter was going by train from city A to city B, and as usual, was sleeping.
Then he woke up, started to look through the window, and noticed that every railway station
has a flag of a particular color.
The boy started to memorize the order of the flags' colors that he had seen. But soon he fell
asleep again. Unfortunately, he didn't sleep long, he woke up and went on memorizing the
colors. Then he fell asleep again, and that time he slept till the end of the journey
At the station, he told his parents about what he was doing and wrote two sequences of the
colors that he had seen before and after his sleep, respectively. Peter's parents know that their
son likes to fantasize. They give you the list of the flags' colors at the stations that the train
passes sequentially on the way from A to B and ask you to find out if Peter could see those
sequences on the way from A to B, or from B to A. Remember, please, that Peter had two
periods of wakefulness.
Peter's parents put lowercase Latin letters for colors. The same letter stands for the same
color, different letters — for different colors.
Advantages: -
2. It is often crowded.
3. speed.
5. Close quarters.
6. Lack of control
7. its inflexibility
Future enhancements: -
SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language: C
Operating system: Windows XP or later.
Tools: DEV C++
HARDWARE REQUIREMENTS:
The hardware requirements that map towards the software are as follows:
RAM:16GB
STEP 1: START
STEP 2:
Declare 4 variables a, b, c, d
STEP 5: using string function check whether the string “A” is a substring of S or not if found return
the value to pointer PM or return null to the pointer
STEP 6: If STEP 5 is true then check whether the string “B” is a substring of the values stored in p
after removing the string A
STEP 7: Read C. Find the length of c and swap the position of array elements using loop store the
swapped positions in array C
STEP 8: Continue STEP 5 AND STEP 6 using string B has main string and pointer Q and substrings I
and Y
#include<stdio.h>
#include<string.h>
int main()
int i,j;
char text[100000],pattern1[102],pattern2[102];
scanf("%s",text);
scanf("%s",pattern1);
scanf("%s",pattern2);
int forwardd=0,reversee=0;
if(match(text,pattern1,pattern2)==1)
forwardd=1;
if(revmatch(text,pattern1,pattern2)==1)
reversee=1;
printf("forward\n");
printf("both\n");
printf("backward\n");
printf("fantasy\n");
return 0;
}
int match(char text[],char pat1[],char pat2[])
int m=strlen(pat1),n=strlen(text),o=strlen(pat2),x=0;
for(int i=0;i<n;i++)
if(text[i+j]!=pat1[j])
break;
if(j==m-1)
i+=m;
for(;i<n;i++)
if(text[i+j]!=pat2[j])
break;
if(j==o-1)
x=1;
return x;
}
}
return x;
int m=strlen(pat1),n=strlen(text),o=strlen(pat2),y=0;
for(int i=n-1;i>=0;i--)
if(text[i-j]!=pat1[j])
break;
if(j==m-1)
i-=m;
for(;i>=0;i--)
if(text[i-j]!=pat2[j])
break;
if(j==o-1)
y=1;
return y;
}
}
return y;
}
OUTPUTS
CONCLUSION& FUTURE WORK
This project is successfully completed to the extent possible. The results of the project
are shown earlier. By the end of this project, we learned many keywords in c. We learned the strings
concept in c. We are now able to design various types of strings and their functions