You are on page 1of 16

K L UNIVERSITY

FRESHMAN ENGINEERING DEPARTMENT


A Project Based Lab Report

On

PETYA AND STAIRCASES


Pr

SUBMITTED BY:

I.D NUMBER NAME

2000031022 T.ASRITH

2000031029 P.UDAYSAI

2000031030 U.LALITH KUMAR

2000031035 V.INDHASENA REDDY

UNDER THE ESTEEMED GUIDANCE OF

Dr . Y.AYYAPPA
Associate Professor

KL UNIVERSITY
Green fields, Vaddeswaram – 522 502
Guntur Dt., AP, India.
DEPARTMENT OF BASIC ENGINEERING SCIENCES

CERTIFICATE

This is to certify that the project based laboratory report entitled


“ANAGRAM SEARCH” submitted by “MY TEAM MEMBERS” bearing R to the Department
of Basic Engineering Sciences, KL University in partial fulfillment of the requirements
for the completion of a project based Laboratory in “Computational Thinking and
Designing” course in I B Tech I Semester, is a bonafide record of the work carried out by
him/her under my supervision during the academic year 2020 – 2 021.

PROJECT SUPERVISOR HEAD OF THE DEPARTMENT

Dr. E. Sreedevi Dr. D.HARITHA

ACKNOWLEDGEMENTS
It is great pleasure for me to express my gratitude to our honorable President Sri.
Koneru Satyanarayana, for giving the opportunity and platform with facilities in
accomplishing the project based laboratory report.

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 <name> for his/her novel
association of ideas, encouragement, appreciation and intellectual zeal which motivated
us to venture this project successfully.

Finally, it is pleased to acknowledge the indebtedness to all those who devoted


themselves directly or indirectly to make this project report success.

NAME ID NUMBER:

T.ASRITH 2000031022

P.UDAYSAI 2000031029

U.LALITH KUMAR 2000031030

V.INDRASENA REDDY 2000031035


PROJECT QUESTION

Little boy Petya loves stairs very much. But he is bored from simple going up and down them
— he loves jumping over several stairs at a time. As he stands on some stair, he can either jump
to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya
doesn't want to step on them.
Now Petya is on the first stair of the staircase, consisting of n stairs. He also knows the numbers
of the dirty stairs of this staircase. Help Petya find out if he can jump through the entire staircase
and reach the last stair number n without touching a dirty stair once.
One has to note that anyway Petya should step on the first and last stairs, so if the first or the
last stair is dirty, then Petya cannot choose a path with clean steps only.
Input
The first line contains two integers n and m (1 ≤ n ≤ 109, 0 ≤ m ≤ 3000) — the number of stairs
in the staircase and the number of dirty stairs, correspondingly. The second line contains m
different space-separated integers d1, d2, ..., dm (1 ≤ di ≤ n) — the numbers of the dirty stairs (in
an arbitrary order).
Output
Print "YES" if Petya can reach stair number n, stepping only on the clean stairs. Otherwise print
"NO".
Examples
input

10 5

24836

output
NO

input
10 5

24579

output
YES
INDEX
S.NO TITLE PAGE NO

1 Introduction <1-4>

2 Aim of the Project <5>

2.1 Advantages & Disadvantages <5>

2.2 Future Implementation <5>

3 Software & Hardware Details <6>

4 Data Flow Diagram <7>

5 Implementation <9-10>

6 Algorithm for each module <8>

7 Integration and System Testing <11>

8 Conclusion <12>
INTRODUCTION

THOREY WE USED IN PROJECT :

Firstly we used the header files named as given below :


1.stdio.h
1.we used stdio.h header file because it is used to store and
Print values of the given data
stdio.h(“STANDARD INPUT OUTPUT

Next we used some user-defined functions because of the


advantages that are mentioned below :
a .The program will be easier to understand ,maintain
and debug .
b . Reusable codes that can be used in other programs .
c . A large program can be divided into smaller modules .
hence ,a large project can be divided among many
programmers .

Next mainly in any program to write a code we use a function


Named as main() . the "main" function is treated the same as every
function, it has a return type (and in some cases accepts inputs via
parameters). The only difference is that the main function is "called" by the
operating system when the user runs the program. Thus the main function
is always the first code executed when a program starts.

Each variable in C has an associated data type. Each data type requires
different amounts of memory and has some specific operations which
can be performed over it. Let us briefly describe them one by one:
Following are the examples of some very common data types used in C:
• int: As the name suggests, an int variable is used to store an
integer.

An array is a data structure that contains a group of elements. Typically


these elements are all of the same data type, such as an integer or string.
Arrays are commonly used in computer programs to organize data so
that a related set of values can be easily sorted or searched .

Generally in any program we use scanf() and printf()

Scanf() is used to take input value whereas

Printf() is used to print output value

The syntax for scanf will be (“%format specifier” ,&variable);

We use “&” symbol because The ampersand (&) allows us to pass the
address of variable number which is the place in memory
where we store the information that scanf read.

For printf the syntax will be (“%format specifier “ , variable);

To write our code we need to repeat a sequential order to perform


Some conditions. So for that u need to use a loop .One of them in that is
for loop.
A for loop is a repetition control structure which allows us to write
a loop that is executed a specific number of times. The loop enables us to
perform n number of steps together in one line. In for loop, a loop variable
is used to control the loop

Below are the steps that how for loop works :


• The initialization statement is executed only once.
• Then, the test expression is evaluated. If the test expression is
evaluated to false, the for loop is terminated.
• However, if the test expression is evaluated to true, statements inside
the body of for loop are executed, and the update expression is
updated.
• Again the test expression is evaluated.
This process goes on until the test expression is false. When the test
expression is false, the loop terminates.

Further , we used the increment and decrement operator in

Which increment is used to increase the value

And decrement is used to decrease the value

We also used “goto “ which is used to provides an unconditional jump


from the 'goto' to a labeled statement in the same function.

STEP BY STEP DECODING OF OUR CODE :

1 . Firstly , we used the header files stdio.h

2 . then we written the function named as count 1 .

In that we used int n,ma[]


And again we declared a new variable of int x

3 . Then we written another function named as count2

4. now scan the values of n,m

5.And we used for(int i=0; i<m; i++)

6.now we scan the value of scanf("%d",&i);

7.we printed the statement as YES

8.So,we are using the if else statement else


if(a[0]==1||a[m-1]==n).

9. int cont=0;
int flag=1;

AIM

Little boy Petya loves stairs very much. But he is bored from simple going up and down them
— he loves jumping over several stairs at a time. As he stands on some stair, he can either jump
to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya
doesn't want to step on them.
Now Petya is on the first stair of the staircase, consisting of n stairs. He also knows the numbers
of the dirty stairs of this staircase. Help Petya find out if he can jump through the entire staircase
and reach the last stair number n without touching a dirty stair once.
One has to note that anyway Petya should step on the first and last stairs, so if the first or the
last stair is dirty, then Petya cannot choose a path with clean steps only.
SYSTEM REQUIREMENTS

➢ SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language : c
Operating system: Windows Xp or later.

➢ HARDWARE REQUIREMENTS:
The hardware requirements that map towards the software are as follows:

RAM :

Processor : i7
DATA FLOW DIAGRAM

start

Read int n,m,a[0];

Now
scanf("%d",
&i)

yes no If no
printf(" If yes if(flag==1)
YES\n") then int Printf as no
; cont=0;

int printf("NO\n")
flag=1; ;

Use return 0

for(int stop
i=2;i<m;i
++)
ALGORITHM

Step 1: start
Step 2: read stdio.h
Step 3:now int n,m,a[0]
Step 4:now scan the n,m values
Step 5:now print those values
Step 6:use if else statement for if yes or no
Step 7:if yes int cont=0;
int flag=1;
for(int i=2;i<m;i++)
{
if(a[i]-a[i-2]<=2)
{
printf("YES\n");
flag=0;
Step 8:if no if(flag==1)
printf("NO\n");
Step 9: stop
IMPLEMENTATION
//PETYA AND STAIRCASES

#include<stdio.h>

int main()

int n,m,a[0];

while(scanf("%d %d",&n,&m));

for(int i=0; i<m; i++)

scanf("%d",&i);

if(m>=n)

printf("YES\n");

else

if(a[0]==1||a[m-1]==n)

printf("YES\n");

else
{

int cont=0;

int flag=1;

for(int i=2;i<m;i++)

if(a[i]-a[i-2]<=2)

printf("YES\n");

flag=0;

break;

if(flag==1)

printf("NO\n");

return 0;

}
INTEGRATION AND SYSTEM TESTING
OUTPUTS
Screen Shots:
CONCLUSION
WE PROVED THAT: Help Petya find out if he can jump through the entire staircase
and reach the last stair number n without touching a dirty stair once.

You might also like