
Write a C program that formats product information entered by the user. The item code can be any number between 100 and 999, price is a dollar amount up to $9999.99 and date should be in mm/dd/yy format. Save the program in a file named as display.c, and submit the file online as your solution to this question. A session with the program should look like this:
#include<stdio.h>
#include<conio.h>
int main()
{double price;
int item;
char date[11];
printf("Enter item number: ");
scanf("%d",&item);
printf("Enter unit price: ");
scanf("%lf",&price);
printf("Enter Purchase Date: ");
scanf("%s",&date);
printf("Item\tUnit\t\tPurchase\n\tPrice\t\tDate\n");
printf("%d\t$%7.2f\t%s\n",item,price,date);
getch();
return 0;
}
Comments
Post a Comment