#include <stdio.h>


int main()
{
    char membershiptype;
        int purchase;
        //float monthly_reward;
    // enter membership type;
    printf("membership type: ");
    scanf("%c", &membershiptype);
        printf("Standard = S , Plus = P , Premium = A");

switch(membershiptype)
    {


        case 'S':

                      printf("\n\nEnter the total monthly purchase :RM");
                      scanf("%d", &purchase);
                      if (purchase < 75)
                      printf("\nMonthly Reward :RM%.0f \n\n",(purchase*0.05)); 
                      else if (purchase > 75 && purchase < 149.99)
                      printf("\nMonthly Reward :RM%.0f \n\n",(purchase*0.075));
                      else if (purchase > 150)
                      printf("\nMonthly Reward :RM%.0f \n\n",(purchase*10.0));

              break;

                case 'P':

                      printf("\n\nEnter the total monthly purchase :RM");
                      scanf("%d", &purchase);
                      if (purchase < 150)
                      printf("\nMonthly Reward :RM%.0f \n\n",(purchase*0.06)); 
                      else if (purchase > 150)
                      printf("\nMonthly Reward :RM%.0f \n\n",(purchase*13.0));

                     break;

            case 'A':

                     printf("\n\nEnter the total monthly purchase :RM");
                     scanf("%d", &purchase);
                     if (purchase < 200)
                     printf("\nMonthly Reward :RM%.0f \n\n",(purchase*0.04));
                     else if  (purchase > 200)
                     printf("\nMonthly Reward :RM%.0f \n\n",(purchase*0.15));

                    break;

        default:
            printf("Invalid Membership");
    } // end of switch
}

You could simplify this by only putting the calculation of the monthly reward in the switch statement, i.e.

    double reward;

    /* printf/scanf statements to get membership and monthly purchase */

    switch(membershiptype)
    {
        /* Cases to calculate the monthly reward and store in reward */
    }

    /* printf statements to output final messages and the achieved monthly reward */

Effectively separate out the logic from the user interface. This is alwaysa good thing to learn to do because in real life the UI often changes while the logic stays the same so you don't want your logic code mixed up with your UI code.

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.