I've been dealing with this problem for about 2 days now.

Write a program that accepts the price of an item and displays the discounted price. Accept also the amount given by the customer (assume the amount is greater than or equal to the discounted price) and display the change.

I'm having errors with the "Write a program that accepts the price of an item and displays the discounted price" part. Declaration of syntax error in function main.

And many other problems..

Help? (Cute Sad Face)

What is the code that you have and what is the error the compiler is giving you?

I'm stuck on the making the discount part:

{float num1, num2, prod, diff;
printf("Enter item price:");
scanf("%f, &num1");
prod = num1 * 0.50
printf("%.2f * %.2f = %.2f\n" num1, prod)

  1. You missing #include <stdio.h>
  2. Your missing int main(). Main returns an int.
  3. Everything in your scanf is a string. Remove the quotes.
  4. Lines 5 and 6 are missing ;.
  5. printf is expecting 3 numbers, yet you only gave it 2.
  6. getch() does not exist in the C standard. Use getchar() instead.
  7. You're not using num2 or diff, so remove them.
  8. Give everything better names! For example price and discounted_price.

Since you're posting in the C++ thread, at least use the corresponding I/O functions: Click Me!

In your case, you're "syntax error" comes from the lines 5 and 6... you forgot the ';' ending character.

Regarding the logic of the program:

What is the discount in your problem? Is a number appliend to the original price to reduce it with the given percent:

discount_price = original_price - (original_price * discount_percent)

That is:

#include <iostream>   // input/output operations

int main() {
    float discount = 50. / 100, price;
    std :: cout << "Original price: " << std :: endl; // output
    std :: cin >> price;                              // input

    // TODO - insert discount logic here

    return 0;