I am receiving this error
markup.c: In function ‘GetPrice’:
markup.c:16:23: error: ‘markup’ undeclared (first use in this function)
markup.c:16:23: note: each undeclared identifier is reported only once for each function it appears in
markup.c:17:1: error: ‘output’ undeclared (first use in this function)

here is my codes

    // File: markup.c



        #include<stdio.h>
        // define the value for constant MARKUP


        #define MARKUP 0.1
        float GetPrice(float finalvalue)
        {
        finalvalue=finalvalue-markup*100;
        output=finalvalue;
        return (float)output;
        }



    int main()
    {
    // declare variables

    char proceed;

    float markupvalue;

    float value;

    float finalvalue; 

    float markup=0.1;
    // ask user if they want to use markup calculator
    printf("Would you like to markup an item? y/n:");
        scanf("%c", &proceed);

        // if yes, proceed to next step
        if(proceed == 'y')
        {

    // ask user what item they want to markup
    printf("please enter item value you would like to markup:");
    scanf("%f", &value);

    // print current of an item
    printf("The value you entered is: %c%.2f\n",'$',value);

    // display current markup rate
    printf("The current markup rate is %.1f%c.\n",markup*100,'%');

    finalvalue=(value-markup*100);
    // final price of an item
    printf("The price for your item after markup is: %c%.2f\n",'$',(float)GetPrice(finalvalue));

    }else
    // display this message if user don't want to use markup calculator
    printf("If you didn't want to markup an item you can leave. \n\n");

    // display end message
     printf("Thank you for using Markup Calculator. \n");
    return 0;
    }

Recommended Answers

All 3 Replies

where is markup defined in getprice() ? if you trying to use the macro defined, then it is MARKUP (in capitals) not markup. change it to capitals or define another markup in getprice() as shown:

int markup=9;

or any value which you want. try it and thanks.

Take note to what nitin1 said, however, there are other issues.

  1. In your Getprice() function you didn't variable output was not declared. It just came out of the blues. These I did to make it work:

        #define MARKUP 0.1
    
        float GetPrice(float finalvalue)
        {
        finalvalue = finalvalue - MARKUP * 100;  // markup was used
        float output = finalvalue;  // you don't really need output
        return (float)output;
        }
    

But really, I don't know why you need to still have to use another variable, when all you can do it just return the "finalvalue".

  1. In your main() function, the variable "markupvalue" was not also used. Though, your code will complie and run, but you might what to also check that.

Hope this help

C is Case Sensitive it means you must use all variables, macros, functions, ets as is in decleration.
You also have to declare all variables before you are using them.
I recommend you to use Camel Notation in naming of everythings except macros.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.