Professional Documents
Culture Documents
Code:
// If id is 9999
if(id == 999)
// Exit from loop
break;
// If id is greater than 5
else if(id > 4)
// Print error
printf("Wrong input! Please, try again!\n");
// If is is valid
else
{
printf("******\n");
// Print car year
printf("Car info: %0.0f ", database[id-1][3]);
// If car type is 10
if(database[id-1][0] == 10)
{
printf("Hatchback\n");
}
// If car type is 20
else if(database[id-1][0] == 20)
{
printf("Sedan\n");
}
// If car type is 30
else if(database[id-1][0] == 30)
{
printf("SUV\n");
}
// If car type is 40
else if(database[id-1][0] == 40)
{
printf("Minivan\n");
}
// Driver program
int main()
{
// 2D array to contain car database
float database[4][5];
// Loop varibales
int i, j;
printf("*** EGAILA CAR SALES AGENCY DATABASE ***\n\n");
printf("WELCOME TO SYSTEM,\n\n");
// Loop from 0 to 3
for(i = 0; i < 4; i++)
{
// Take car information
printf("Please enter body type, engine size, mileage, year and price of
the car #%d >> ",i + 1);
scanf("%f %f %f %f
%f",&database[i][0],&database[i][1],&database[i][2],&database[i][3],&databa
se[i][4]);
return 0;
}
output: