You are on page 1of 16

K L UNIVERSITY

FRESHMAN ENGINEERING DEPARTMENT


A Project Based Lab Report

On

Rank List

SUBMITTED BY:

I.D NUMBER NAME

2000030546 LIKHITHA GANGAVARAPU

2000030558 M NAGA VENKATA SAI

2000030570 M.N. P HEMANTH KUMAR

2000030572 MAHUPALLY JAHNAVI

UNDER THE ESTEEMED GUIDANCE OF

Y. AYYAPPA

ASSISTANT 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


“RANK LIST” submitted by Mr./Ms. MACHUPALLY JAHNAVI bearing Regd. No.
2000030572 to the Department of Basic Engineering Sciences, KL University
in partial fulfillment of the requirements for the completion of a project in
“Object Oriented Programming” course in I B Tech II Semester, is a bonafide
record of the work carried out by him/her under my supervision during the
academic year 2019-20.

PROJECT SUPERVISOR HEAD OF THE DEPARTMENT

Y.AYYAPPA 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 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 Y.AYYAPPA 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: MACHUPALLY JAHNAVI

Regd . No: 2000030572


ABSTRACT
Another programming contest is over. You got hold of the contest's final results table.
The table has the following data. For each team we are shown two numbers: the number
of problems and the total penalty time. However, for no team we are shown its final
place.
You know the rules of comparing the results of two given teams very well. Let's say
that team a solved pa problems with total penalty time ta and team b solved pb problems
with total penalty time tb. Team a gets a higher place than team b in the end, if it either
solved more problems on the contest, or solved the same number of problems but in less
total time. In other words, team a gets a higher place than team b in the final results'
table if either pa > pb, or pa = pb and ta < tb.
It is considered that the teams that solve the same number of problems with the same
penalty time share all corresponding places. More formally, let's say there is a group of x
teams that solved the same number of problems with the same penalty time. Let's also say
that y teams performed better than the teams from this group. In this case all teams from
the group share places y + 1, y + 2, ..., y + x. The teams that performed worse than the
teams from this group, get their places in the results table starting from the y + x + 1-th
place.
Your task is to count what number of teams from the given list shared the k-th place.
Input
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 50). Then n lines contain the
description of the teams: the i-th line contains two integers pi and ti (1 ≤ pi, ti ≤ 50) — the
number of solved problems and the total penalty time of the i-th team, correspondingly.
All numbers in the lines are separated by spaces.
Output
In the only line print the sought number of teams that got the k-th place in the final results'
table.

Example:
Input:
72

4 10

4 10

4 10

3 20

21

21
1 10

output
3

input
54

31

31

53

31

31

output
4
INDEX
S.NO TITLE PAGE NO
1 Introduction 1
2 Aim of the Project 2
2.1 Advantages & Disadvantages 2
2.2 Future Enhancement 2
3 Software & Hardware Details 3
4 Algorithm and Flow chart 4-5
5 Implementation 6-8
6 Outputs / Screen Shots 9
7 Conclusion 10

INTRODUCTION

In this project I have used the concept of dynamic memory management in C. The C
programming language provides several functions for memory allocation and
management.

C dynamic memory allocation refers to performing manual memory management


for dynamic memory allocation in the C programming language via a group of functions
in the C standard library, namely malloc, realloc, calloc and free.

File pointer is a pointer which is used to handle and keep track on the files being
accessed. A new data type called “FILE” is used to declare file pointer. This data type is
defined in stdio.h file. File pointer is declared as FILE *fp. Where, ‘fp’ is a file pointer.

fopen() function is used to open a file that returns a FILE pointer. Once file is opened,
file pointer can be used to perform I/O operations on the file. fclose() function is used to
close the file.
Pointers in C are easy and fun to learn. Some C programming tasks are performed more
easily with pointers, and other tasks, such as dynamic memory allocation, cannot be
performed without using pointers. So it becomes necessary to learn pointers to become
a perfect C programmer. Let's start learning them in simple and easy steps.
As you know, every variable is a memory location and every memory location has its
address defined which can be accessed using ampersand (&) operator, which denotes
an address in memory.

AIM
AIM IS TO FIND NUMBER OF TEAMS SHARED A PARTICULAR PLACE.

Advantages:-

1.c is a powerful and efficient language


2.c is a portable language
3.c has built in functions
4.c is a middle level language
5.dynamic memory allocation
Disadvantages:-

1. Low level of abstraction.


2.C show errors after completion whole program
Runtime checking gets difficult.
3. C does not have any constructor or destructor.
4. Lack of Exception Handling.
5. C does not implement the concept of namespaces.
Future enhancements:-

This research is based on number of teams got number of positions and we


have successfully implemented it and in future might ask about this. A
project is normally regarded to be a win on the off chance that it
accomplishes the destinations as indicated by their acknowledgment criteria,
inside a concurred timescale and budget.

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 : 8GB RAM

Processor : Core i5

Tool-Used : Online Gdb


3
Algorithm

Step 1: start
Step 2: declare f, n, k
Step 3: open fp file pointer
Step 4: scan number of teams and place of teams to count.
Step 5:print values in file pointer
Step 6: call check function
Step 6: In check function declare pointers p and t, integers i, j,
c
Step 7: allocate memory to pointers p and t using malloc.
Step 8: for(i=0; i<n; i++) scan place and time of team in
competition.
Step 9: for(i=0; i<n; i++) if(p[i]==p[k-1]) increment c by 1.
Step 10: return c to main function
Step 11: print value of c as count output
Step 12: stop.

4
FLOW CHART

5
IMPLEMENTATION

#include<stdio.h>
#include<malloc.h>
int check(int n,int k)
{
int *p,*t;
int i,j,c=0;
p=(int *)malloc(n*sizeof(int));
t=(int *)malloc(n*sizeof(int));
FILE *fp;
fp=fopen("data","a");
fprintf(fp,"data\n");
printf("enter scores and time\n");
for(i=0;i<n;i++)
{
scanf("%d",(p+i));
fprintf(fp,"%d\t",p[i]);
scanf("%d",(t+i));
fprintf(fp,"%d\t",t[i]);
6
}
for(i=0;i<n;i++)
{
if(p[i]==p[k-1])
{
c++;
}
}
return c;
}
int main()
{
int f,n,k;
FILE *fp;
fp=fopen("data","a");
printf("quetion:12 batch:5 \n");
printf("enter no.of teams and place to count:\n");
scanf("%d\t",&n);
fprintf(fp,"%d",n);
scanf("%d",&k);
fprintf(fp,"\t%d\n",k);
7
f=check(n,k);
printf("no.of teams shared %dth place=%d",k,f);
fprintf(fp,"no.of teams=%d\n",f);
return 0;
}
Data file :

8
OUTPUTS

Screen Shots:

9
CONCLUSION

It was a wonderful learning experience for me while


working on this project. We have designed this program
and tested it in real time. It is easy to identify how many
number of teams shared which place if n number of teams
and their positions given. It has low space complexity, high
performance and provides optimal solution.

10

You might also like