Professional Documents
Culture Documents
K L University Freshman Engineering Department: A Project Based Lab Report On Rank List
K L University Freshman Engineering Department: A Project Based Lab Report On Rank List
On
Rank List
SUBMITTED BY:
Y. AYYAPPA
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.
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.
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:-
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:
Processor : Core i5
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
10