Computer Science, asked by chavanshruti87, 9 months ago

An automobile company has serial number for engine parts starting from AA0 to FF9. The other characteristics of parts to be specified in a structure are: Year of manufacture, material and quantity manufactured.
(a) Specify a structure to store information corresponding to a part.
(b) Write a program to retrieve information on parts with serial numbers between BB1 and CC6.

Answers

Answered by kotaravi54321
3

Explanation:

The coding is given below.

It is possible when keying in the parts key alphabets in uppercase.

void main()

{

int i,j,letter,a,b,c,d;

char m[3],n[3],q[1];

struct parts

{

int year;

char material[20];

int qty;

};

struct parts p[27]={

{1991,""rubber"",5},{1992,""rubber"",6},{1991,""metal"",7},{1997,""wood"",8},{1993,""plastic"",9},{1992,""wood"",6},{1997,""metal"",6},{1992,""rubber"",7},{1991,""wood"",2},

{1992,""metal"",6},{1995,""wood"",4},{1992,""rubber"",5},{1998,""wood"",2},{1997,""plastic"",8},{1998,""plastic"",9},{1998,""metal"",8},{1991,""metal"",8},{1992,""wood"",5},

{1993,""wood"",8},{1993,""rubber"",7},{1997,""metal"",2},{1998,""wood"",1},{1999,""plastic"",8},{1995,""wood"",6},{1990,""rubber"",3},{1997,""plastic"",9},{1998,""wood"",7}

};

/* for(i=0,letter=65;i<2;i++,letter++)

{

for(j=0;j<9;j++)

{

printf(""\Key in values for year,material and quantity respectively for part %c%c%d\n"",letter,letter,j+1);

scanf(""%d%s%d"",&p[i][j].year,&p[i][j].material,&p[i][j].qty);

}

} */

while(1)

{

clrscr();

printf(""\nKey in the part number to retrieve the information from\n"");

scanf(""%s"",m);

printf(""\nKey the part number till the information is retrieved(End)\n"");

scanf(""%s"",n);

a=((m[0]-65)*9+(m[2]-49));

b=((n[0]-65)*9+(n[2]-49));

printf(""\na is %d,\nb is %d,\nm[0] is %d, n[0] is %d"",a,b,m[0],n[0]);

c=a;

d=a;

while(c>=9)

{

c-=9;

}

printf(""\nc after while is %d"",c);

while( d>9)

d-=9;

for(i=a;i<=b;i++,c++,d++)

{

if(c==9)

{

m[0]+=1;

c=0;

}

if(d==9)

{

d=0;

}

printf(""\nPart: %c%c%d, Year: %d, Material: %s, Quantity: %d"",m[0],m[0],d+1,p[i].year,p[i].material,p[i].qty);

}

printf(""\nKey q to quit or any other key to continue\n"");

scanf(""%s"",q);

if(q[0]==113)

break;

}

}

Answered by varikutty
16

Answer:

Automobile company structure program.

Posted: January 16, 2012 in Lab 1

0

An automobile company has serial number for engine parts starting from AA0 to FF9.The other characteristics of parts to be specified in a structure are : Year of manufacture, material and quantity manufactured.

a. Specify a structure to store information corresponding to a part.

b. Write a program to retrive information on parts with serial

numbers between BB1 and BB2

#include<stdio.h>

#include<stdlib.h>

int main()

{

struct parts

{

char sl[4],material[10];

int yr,qty;

};

int i;

struct parts p[3];

for(i=0;i<3;i++)

{

printf("Enter sl no\n");

fflush(stdin);

gets(p[i].sl);

printf("Enter yr of manufactur , material and qtty\n");

scanf("%d%s%d",&p[i].yr,&p[i].material,&p[i].qty);

}

for(i=0;i<3;i++)

{

if(p[i].sl[0]=='A')

continue;

if(p[i].sl[0]>=100&&p[i].sl[0]<=102)

continue;

if((p[i].sl[0]=='B'&&p[i].sl[2]=='1')||(p[i].sl[0]=='C'&&p[i].sl[0]>'6'))

continue;

printf("%s %d %s %d\n",p[i].sl,p[i].yr,p[i].material,p[i].qty);

}

return 0;

Explanation:

PLEASE MAKE MY ANSWER AS BRAINLIEST ANSWER BECAUSE I MADE LOTS OF EFFORT FOR THIS ANSWER

Similar questions