Scooter company has serial numbers from AA0 to FF9, the other characteristics of scooter are year of manufacture, colour, horsepower. Use a structure pointer and do the following:
a. Retrieve all information of scooters
within a range BB0 and CC9
b. Display the oldest scooter
#include<stdio.h>
#include<conio.h>
void
main()
{
struct scooter
{
char srno[5];
int year;
char color[10];
int hp;
}sc[10];
int
i,ch,n;
clrscr();
while(1)
{
printf("\n
1:add scooter info");
printf("\n
2:information of scooters within a range BB0 and CC9");
printf("\n
3:Display the oldest scooter");
printf("\n
4:exit");
printf("\n
enter the choice");
scanf("\n
%d",&ch);
switch(ch)
{
case 1:
printf("\n how many record u
add");
scanf("\n
%d",&n);
for(i=0;i<n;i++)
{
printf("\n
enter sr no");
scanf("\n
%s",&sc[i].srno);
printf("\n
enter year");
scanf("\n
%d",&sc[i].year);
printf("\n
enter color");
scanf("\n %s",&sc[i].color);
printf("\n
enter hp");
scanf("\n
%d",&sc[i].hp);
}
break;
case
2:
for(i=0;i<n;i++)
{
if(sc[i].srno>="bb0" ||
sc[i].srno<="cc9")
{
printf("\n srno is%s",sc[i].srno);
printf("\n
year is%d",sc[i].year);
printf("\n
color is%s",sc[i].color);
printf("\n
hp is%d",sc[i].hp);
}
}
break;
case
3:printf("\n the oldest scooter is %c",sc[0]);
printf("\n srno
is%s",sc[0].srno);
printf("\n
year is%d",sc[0].year);
printf("\n
color is%s",sc[0].color);
printf("\n
hp is%d",sc[0].hp);
break;
case
4:exit(0);
}
}
getch();
}