A Maruti car dealer maintain a record of sales of various vehicles in the follwing form:
Vehicle type Month of sales Price
MARUTI-800 02/01 210000
MARUTI-DX 07/01 265000
GYPSY 04/02 315750
MARUTI-VAN 08/02 240000
Write a program to read this data into a table of strings and output the details of a particular vehicle sold during a specified period. The program should request the user to input the vehicle type and the period (starting month, ending month).
#include <stdio.h>
void main()
{
char vt[50][20],price[20][20];
int sm[20],em[20],i,count=0,end;
clrscr();
for(i=1;i<=20;i++)
{
printf("If you want end process than type -999 else 0:");
scanf("%d",&end);
if(end==-999)
break;
printf("Enter vehicle type:");
scanf("%s",vt[i]);
printf("Enter the starting and ending months of sales\n");
scanf("%d %d",&sm[i],&em[i]);
printf("Enter price:");
scanf("%s",price[i]);
count++;
}
clrscr();
printf("Vehicle Type Month of sale Price\n");
printf("------------------------------------\n");
for(i=1;i<=count;i++)
{
printf("%-12s %4d/%d %10s",vt[i],sm[i],em[i],price[i]);
putchar('\n');
}
getch();
}
Vehicle type Month of sales Price
MARUTI-800 02/01 210000
MARUTI-DX 07/01 265000
GYPSY 04/02 315750
MARUTI-VAN 08/02 240000
Write a program to read this data into a table of strings and output the details of a particular vehicle sold during a specified period. The program should request the user to input the vehicle type and the period (starting month, ending month).
#include <stdio.h>
void main()
{
char vt[50][20],price[20][20];
int sm[20],em[20],i,count=0,end;
clrscr();
for(i=1;i<=20;i++)
{
printf("If you want end process than type -999 else 0:");
scanf("%d",&end);
if(end==-999)
break;
printf("Enter vehicle type:");
scanf("%s",vt[i]);
printf("Enter the starting and ending months of sales\n");
scanf("%d %d",&sm[i],&em[i]);
printf("Enter price:");
scanf("%s",price[i]);
count++;
}
clrscr();
printf("Vehicle Type Month of sale Price\n");
printf("------------------------------------\n");
for(i=1;i<=count;i++)
{
printf("%-12s %4d/%d %10s",vt[i],sm[i],em[i],price[i]);
putchar('\n');
}
getch();
}
No comments:
Post a Comment