Automobile company structure program.

Posted: January 16, 2012 in Lab 1

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 CC6.

#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;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s