Q1.
#include<stdio.h>
struct automob {
char name[5];
int year;
char mtr[10];
int qty;
};
void main() {
struct automob a[54]={{"AA1",2009,"AAA",10},
{"AA2",2009,"AAA",10},
{"AA3",2009,"AAA",10},
{"AA4",2009,"AAA",10},
{"AA5",2009,"AAA",10},
{"AA6",2009,"AAA",10},
{"AA7",2009,"AAA",10},
{"AA8",2009,"AAA",10},
{"AA9",2009,"AAA",10},
{"BB1",2010,"BBB",11},
{"BB2",2010,"BBB",11},
{"BB3",2010,"BBB",11},
{"BB4",2010,"BBB",11},
{"BB5",2010,"BBB",11},
{"BB6",2010,"BBB",11},
{"BB7",2010,"BBB",11},
{"BB8",2010,"BBB",11},
{"BB9",2010,"BBB",11},
{"CC1",2011,"CCC",12},
{"CC2",2011,"CCC",12},
{"CC3",2011,"CCC",12},
{"CC4",2011,"CCC",12},
{"CC5",2011,"CCC",12},
{"CC6",2011,"CCC",12},
{"CC7",2011,"CCC",12},
{"CC8",2011,"CCC",12},
{"CC9",2011,"CCC",12},
{"DD1",2012,"DDD",13},
{"DD2",2012,"DDD",13},
{"DD3",2012,"DDD",13},
{"DD4",2012,"DDD",13},
{"DD5",2012,"DDD",13},
{"DD6",2012,"DDD",13},
{"DD7",2012,"DDD",13},
{"DD8",2012,"DDD",13},
{"DD9",2012,"DDD",13},
{"EE1",2013,"EEE",14},
{"EE2",2013,"EEE",14},
{"EE3",2013,"EEE",14},
{"EE4",2013,"EEE",14},
{"EE5",2013,"EEE",14},
{"EE6",2013,"EEE",14},
{"EE7",2013,"EEE",14},
{"EE8",2013,"EEE",14},
{"EE9",2013,"EEE",14},
{"FF1",2014,"FFF",15},
{"FF2",2014,"FFF",15},
{"FF3",2014,"FFF",15},
{"FF4",2014,"FFF",15},
{"FF5",2014,"FFF",15},
{"FF6",2014,"FFF",15},
{"FF7",2014,"FFF",15},
{"FF8",2014,"FFF",15},
{"FF9",2014,"FFF",15}};
int i,j,k;
printf("Information of parts between BB1 to CC6:\n\n");
printf("\n\nName\t\tyear(manu.)\t\tmaterial\tquantity\n\n\n");
for(i=0;i<54;i++) {
if(i>=9 && i<=23) {
printf("%3s\t\t%4d\t\t\t%5s\t\t%4d\n",a[i].name,a[i].year,a[i].mtr,a[i].qty);
}
}
}
{
struct crc
{
char name [20];
int age;
int test;
int avg;
} c[20];
int x=0,i=0,j=0,k=0,a=0;
int code,amount=0; char cusacc;
int current_b=0;
printf("Enter how many cricketer data you want to enter ;Limit 20\n");
scanf("%d", &x);
printf("Enter Name, age and avg score and no of test matches for each user respectively:\n");
for (i=0;i<x;i++)
{ printf("\nenter name of%d cricketer is =",a+1);
scanf (" %s", &c[i].name);
printf("\nenter age of cricketer is=");
scanf (" %d",&c[i].age);
printf("\nenter no of test matches=");
scanf (" %d",&c[i].test);
printf("\nenter avg score=");
scanf (" %d",&c[i].avg);}
printf("\n\nData of All The cricketer:");
printf("\nName\t\t Account Number\t\t Balance\
n_______________________________________");
for(i=0;i<x;i++)
{
printf ("\n\n name of %d cricketer is= %s\t\age of cricketer=%d\t\tno of test matches is= %d\t\tavg
score= %d",a+1,c[i].name,c[i].age,c[i].test,c[i].avg);
}
printf ("Name\t\tAccount Number\n___________________________________________");
}
Q3.
#include<stdio.h>
struct studata
{
int roll;
char name[50];
char depart[50];
char course[20];
int yoj;
}nos[450] = { 03, "Kishor", "IT", "[Link]", 2014,
10, "Mohammad Siraj Alam", "Computer Science", "[Link]", 2014,
53, "Deepak", "Computer Applications", "BCA", 2013,
13, "Karan", "Mechanical", "Diploma", 2013,
1, "Aakash", "Tool and Die", "Diploma", 2012,
2, "Ramesh", "IT", "[Link]", 2014
};
void student_in_year(int year)
{
int i;
printf("\n\t\tYear of joining : %d\n\n", year);
for (i = 0; i <= 450; i++)
{
if (nos[i].yoj == year)
{
printf("\nRoll Number : %d", nos[i].roll);
printf("\nName : %s", nos[i].name);
printf("\nDepartment : %s", nos[i].depart);
printf("\nCourse : %s\n", nos[i].course);
}
}
}
void student_data(int enroll)
{
int i;
printf("\nRoll number : %d", enroll);
for (i = 0; i <= 450; i++)
{
if (nos[i].roll == enroll)
{
printf("\nName : %s", nos[i].name);
printf("\nDepartment : %s", nos[i].depart);
printf("\nCourse : %s\n", nos[i].course);
printf("\nYear of joining : %d\n", nos[i].yoj);
}
}
}
int main()
{
int yoj, roll;
printf("\nEnter year of joining of the students : ");
scanf("%d", &yoj);
student_in_year(yoj);
printf("\nEnter the roll number of the studnet you want data : ");
scanf("%d", &roll);
student_data(roll);
return 0;
}
Q4.
#include<stdio.h>
void action(int, int, int);
void below100();
struct acc_holder
{
long int acc_num;
char name[30];
int bal;
} sbi[200] = { 1, "Siraj", 1000000,
2, "Azad", 1233044,
3, "Deepak", 99,
4, "Rihan", 33,
5, "Rahul Khowal", 200000
};
int main()
{
int accnum, amount, code;
printf("\nEnter your account number : ");
scanf("%d", &accnum);
printf("Enter 1 for deposit and 0 for withdrawal : ");
scanf("%d", &code);
if (code)
{
printf("\nEnter amount to be deposit : ");
scanf("%d", &amount);
}
else
{
printf("\nEnter amount to withdraw : ");
scanf("%d", &amount);
}
action(accnum, amount, code);
printf("All members with account balance less than 100 are following : ");
below100();
return 0;
}
void below100()
{
int i;
for (i = 0; i < 200; i++)
{
if (sbi[i].bal < 100 && sbi[i].bal > 0)
{
printf("\nName : %s", sbi[i].name);
printf("\nAccount Number : %d\n\n", sbi[i].acc_num);
}
}
}
void action(int accnum, int amount, int code)
{
int i;
for (i = 0; i < 200; i++)
if (sbi[i].acc_num == accnum)
break;
if (!code)
{
if (sbi[i].bal - amount < 100)
{
printf("\nThe balance is insufficient for the specified withdrawal");
return;
}
else
{
sbi[i].bal -= amount;
printf("\nYour new account balance is : %d\n", sbi[i].bal);
}
}
else
{
sbi[i].bal += amount;
printf("\nYour new account balance is : %d\n", sbi[i].bal);
}