FY_BCA_C_SLIP 21_2



slip no :21_2 A scooter has serial nos from AA0toFF9. Use a structure pointer

-  Retrive all information of scooter within rannnnn BB0 and CC9
-  Display the oldest scooter

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

int 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 info is : "); 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);

default:printf("invalid choice");
}
}
getch();
}

No comments:

Post a Comment