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

EXPECTED PROGRAM (10 MARKS)

Create a structure to specify data of customers in a bank. The data


to be stored is : Account number, name of customer and balance
in account. Assume maximum of 3 customers in the bank. Write a
function to print the account number and name of each customer
with balance below rs. 100.

#include<stdio.h>
#include<conio.h>
struct customer
{
char a_no[10];
char c_name[10];
int bal;
}s[5];
void display();
void main()
{
int i;
clrscr();
for(i=1;i<=3;i++)
{
printf("enter the record of %d customer",i);
printf("\nenter account number: ");
scanf("%s",&s[i].a_no);
printf("enter customer name: ");
scanf("%s",&s[i].c_name);
printf("enter balance: ");
scanf("%d",&s[i].bal);
}
display();
getch();
}
void display()
{
int i;
printf("\nName and Account number of a person whose balance is below 100
are :");
for(i=1;i<=3;i++)
{
if(s[i].bal < 100)
{
printf("\nname: %s",s[i].c_name);
printf(" account number :%s",s[i].a_no);
}
}
}

OUTPUT:

Q.2 Create a structure to specify data on students given below:


Roll_no, name, deptt, course, year_of_passing
Assume that there are not more than 3 students in the
college.
(a) Write a function to print names of all students who
joined in a particular year.
(b) Write a function to print the data of a student whose
roll number is given.
#include<stdio.h>
#include<conio.h>

struct student
{
int rollno;
char sname[30];
char deptt;
char course[30];
int y_o_p;
}s[3];
void display_year(int);
void display_rollno(int);
void main()
{
int i,y,r;
clrscr();
for(i=1;i<=3;i++)

{
printf("Enter the recor of %d student :",i);
printf("\nEnter student rollno : ");
scanf("%d",&s[i].rollno);
printf("Enter student name :");
scanf("%s",&s[i].sname);
printf("Enter department name :");
scanf("%s",&s[i].deptt);
printf("Enter Course Name :");
scanf("%s",&s[i].course);
printf("Enter year of passing :");
scanf("%d",&s[i].y_o_p);
}
printf("\nEnter a particular year for which u want to see the
information :");
scanf("%d",&y);
display_year(y);
printf("\nEnter a rollno of a student whose information u want to see
: ");
scanf("%d",&r);
display_rollno(r);
getch();
}
void display_year(int y)
{
int i;
printf("\n**Name of students who joined in a particular year** ");
for(i=1;i<=3;i++)
{
if(s[i].y_o_p == y)
{
printf("\n %s",s[i].sname);
}
}
}
void display_rollno(int r)
{
int i;
printf("Information of students who rollno is %d",r);
for(i=1;i<=3;i++)
{
if(s[i].rollno == r)
{
printf("\nName is : %s",s[i].sname);
printf("Department : %s",&s[i].deptt);
printf("Course : %s",s[i].course);
printf("Year of Passing : %d",&s[i].y_o_p);
}
}
}

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