0% found this document useful (0 votes)
23 views8 pages

Array of Structures in C Programming

1. The document describes a C programming assignment to declare an array of structures containing player data like name, matches played, and best bowling figures. 2. The program is expected to insert minimum 5 player records, sort by bowling figures, display in tabular format, delete a record, and search by name. 3. The conclusion states that a program was written to insert, sort, delete player data, and search by name as required.

Uploaded by

Omkar Khadilkar
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)
23 views8 pages

Array of Structures in C Programming

1. The document describes a C programming assignment to declare an array of structures containing player data like name, matches played, and best bowling figures. 2. The program is expected to insert minimum 5 player records, sort by bowling figures, display in tabular format, delete a record, and search by name. 3. The conclusion states that a program was written to insert, sort, delete player data, and search by name as required.

Uploaded by

Omkar Khadilkar
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

K. J.

Somaiya College of Engineering, Mumbai-77


(A Constituent College of Somaiya Vidyavihar University)

Batch: E2 Roll No.: 16010320031

Experiment / assignment / tutorial No. 6

Grade: AA / AB / BB / BC / CC / CD /DD

Signature of the Staff In-charge with date

TITLE: Array of Structures.

AIM: Program to declare an array of structure `players` having data members (name,
total matches played, best bowling figure). Program should do the following operations
using functions.

a. Insert Minimum 5 player data in array of structure


b. Sort and display this data in descending order of their best bowling figure (if
wickets are same then consider less run conceded as priority) and in proper
tabular form
c. Delete the data for any one player.
d. Search for a particular player using its name.

______________________________________________________________________
Expected OUTCOME of Experiment:

Use of array and its properties.


_____________________________________________________________________
Books/ Journals/ Websites referred:

1. Programming in C, second edition, Pradeep Dey and Manas Ghosh, Oxford


University Press.
2. Programming in ANSI C, fifth edition, E Balagurusamy, Tata McGraw Hill.
3. Introduction to programming and problem solving , G. Michael Schneider
,Wiley India edition.
4. [Link]

_____________________________________________________________________

Department of Science and Humanities

Page No PIC Sem I/August-December 2020


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

Problem Definition:

Create an array of structure ‘players’ which store information about multiple players
having different data members such as name, total matches played, best bowling figure.
Program should read choice from the user and perform following function:

Choice 1: Insert data in array of structure.


Choice 2: Sort and Display
Choice 3: Delete a player
Choice 4: Traverse and search a player with given name.

Algorithm:

 Step1- Start

 Step2- Define structure

 Step3- Use switch case for insert, sort, delete and search

 Step4- case1- insert player name and data

 Step5- case1-store the player name and data using structures

 Step6- case2-sort by comparing no of wickets if no of wickets is same compare


by less

 no of runs conceded

 Step7- case2-display the player name

 Step8-case3-search the player name

 Step 9-case3-if player name not found display player not found

 Step10-case4- delete the player name and statistics

 Step11-case4-if player name not found display player not found

 Step12 – Stop

Department of Science and Humanities

Page No PIC Sem I/August-December 2020


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

Implementation details:

Department of Science and Humanities

Page No PIC Sem I/August-December 2020


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

Department of Science and Humanities

Page No PIC Sem I/August-December 2020


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

Output(s):

Department of Science and Humanities

Page No PIC Sem I/August-December 2020


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

Conclusion: Hence we wrote a program where we can insert the data for any bowler and
also sort them properly and delete a player and also search for any player’s stats by his name.

Department of Science and Humanities

Page No PIC Sem I/August-December 2020


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

Post Lab Descriptive Questions

1. Comment on the output of the following C code.

#include <stdio.h>
struct temp
{
int a;
int b;
int c;
};
main()
{
struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
}

Ans:
Struct temp is initialized with the above values, in p.a , p.b and p.c, repectively.

2. Consider the following C code. What will be the output?

#include<stdio.h>
struct st
{
int x;
struct st next;
};

int main()
{
struct st temp;
temp.x = 10;
[Link] = temp;
printf("%d", [Link].x);
return 0;
}

(A) Compiler Error


(B) 10
(C) Runtime Error
(D) Garbage Value

Department of Science and Humanities

Page No PIC Sem I/August-December 2020


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)

3. Difference between Structure and Union.


A structure is a user-defined data type available in C that allows to combining data items of
different kinds. Structures are used to represent a record. A union is a special data type
available in C that allows storing different data types in the same memory location.

Date: 20/12/2020 Signature of faculty in-charge

Department of Science and Humanities

Page No PIC Sem I/August-December 2020

You might also like