Вы находитесь на странице: 1из 3

To store the Details of Bank Customers.

Kumar Prince, IIT2019130


Jain Priyanshu, IIT2019131
Bansal Dev, IIT2019132
Azmeera Mounika, IIT2019133
I SEMESTER B. TECH, DEPARTMENT OF INFORMATION
TECHNOLOGY
INDIAN INSTITUTE OF INFORMATION TECHNOLOGY
ALLAHABAD

ABSTRACT: An array of structures can be defined as


the collection of multiple structures
In this paper we have devised an array of
variables where each variable contains
structures in which we have stored the
information about different entities.
details of the customers and used that
The array of structures in Care used to
array of structure to find the name of
store information about multiple entities of
customer whose account balance is less
different data types.
than $200 and given a benefit of $100to
customers with more than $1000 in their
bank account using a predefined
ALGORITHM
function.
START
Step 1: We have firstly defined a structure
INTRODUCTION :
named customer with 3 member data types
Structure is a user-defined datatype as given in the question. We have defined
in C language which allows us to combine account as char data type because the
data of different types account number may have character in it.
together. Structure helps to construct a struct customer
complex data type which is more {
meaningful. char name[100];
char account[30];
It is somewhat similar to an Array, but an
long long m;
array holds data of similar type
};
only. While in structure we can define
different data types and use this derived Step 2: We have asked the user to input
prototype as a derived datatype. the number of records he wants of the
customers and using that number we have
Prototype of a structure
made an array of that size and using the
struct Tag_name
object created from the structure, we have
{
defined the structure. And with the help of
Member 1;
the array we store the information of the
Member 2;
customers.
……..;
int n;
………;
scanf("%d",&n);
…….;
struct customer a[n];
Member n;
for(int i=0;i<n;i++)
};
{
scanf(" %[^\n]%*c",a[i].name); m=0;
scanf(" %s", a[i].account); printf("\n Increased balance in the
scanf(" %lld ",&a[i].m); account of person having starting balance
} more than $1000:\n");
for(int i=0;i<n;i++)
{
Step 3: We have defined a function to find
if(a[i].m>1000)
the names of the customers who have more
{
than $200 in their account and print those
m++;
name and in the same function we have
a[i].m=a[i].m+100;
also incremented $100 to the accounts of
printf("%lld ", a[i].m);
all those customers who have more than
}
$1000 in their accounts.
}
void required (struct customer a[],int n) if(m==0)
{ printf("There is no any person whose
int m=0; initial account balance is more than $1000
printf ("The person having less than ");
$200 in their account \n "); }
for(int i=0;i<n;i++)
STOP.
{
if(a[i].m<200) TIME COMPLEXITY
{
 The time complexity of the code is
m++;
totally dependent on the size of
printf(" %s ",a[i].name);
array. As size will increase all the
}
loop used in the code will run for
if(m==0)
longer time and hence more will be
printf("There is no any person with
the execution time.
account balance less than $200 \n");
}
Size of structure Execution time (in
array sec)
10 0.000835
15 0.001054
20 0.001257
25 0.001530
30 0.001721

CONCLUSION
In this paper we have learnt how to use
structures and to create array of structure.
And we have successfully stored the
records of the customers and used those
records to find the required queries.
REFRENCES
1. The C programming language by
Brian W. Kernighan and Dennis M.
Ritchie.
2. Let us C by Yashwant Kanetkar
3. Geeksforgeeks

Вам также может понравиться