Can't understand what I'm doing wrong.
Write a program which stores coded information about sales for customers. Each customer has a unique number from 1 to 100. The program prompts the user for :
1. the customer number
2. the first letter of the customer's last name
3. the amount of the customer's latest purchase.
It stores the letter in one array and the purchase amount in another. There should be no more than two arrays in your program.
The program will keep asking for this info until the user enters a customer number of zero.
To print the sales amount in dollars and cents, use the $%.2f format specifier.
On screen it should look like this:
customer number? 12
first letter of customer’s last name? J
amount of purchase? 57.62
This is what I have so far:
Code:
#include <stdio.h>
#include <conio.h>
int main() {
int num;
char lastname[1];
float tempnum;
float purchase[100];
do {
printf("Customer number: \n");
scanf("%d", &num);
printf("1st letter: \n"
getche();
char lastname[1] = getche;
printf("Amount of purchase: \n");
scanf("$%.2f", &tempnum);
purchase[100] = tempnum;
} while(num!= '0');
return 0;
}
:confused: I thought I was doing this right, but when I tried to execute this program, it couldn't run beacuse there were errors. :( If anyone could look over what I have and offer some tips on what I' m doing wrong, I would greatly appreciate it.
Thank You. :)