help for c++

This is a discussion on help for c++ within the C++ Programming forums, part of the General Programming Boards category; #define currentSalary 2500 #include <stdio.h> #include <math.h> int main() { char status,f,p; int serviceYears; float newSalary; printf("Enter employee status:"); scanf("%c", ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    29

    Question help for c++

    #define currentSalary 2500
    #include <stdio.h>
    #include <math.h>
    int main()
    {
    char status,f,p;
    int serviceYears;
    float newSalary;
    printf("Enter employee status:");
    scanf("%c", &status);
    printf("Enter year of service:");
    scanf("%d", &serviceYears);
    if(status = 'f')
    {
    if( serviceYears < 5 )
    newSalary = (currentSalary * 0.04) + currentSalary;
    else
    newSalary = (currentSalary * 0.05) + currentSalary;
    }
    else
    if(status = 'p')
    {
    if( serviceYears < 5 )
    newSalary = currentSalary + (currentSalary * 0.02);
    else
    newSalary = currentSalary + (currentSalary * 0.03);
    }
    printf("Your new salary is RM %0.2f\n", newSalary);
    system("pause");
    return 0;
    }



    why can't i get diff ans when input status p?

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,406
    well you should use == not = in your if statements, and use the code tags to show your examples properly
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    29
    thx. n what is code tags?? sorry 4 asking coz i'm new to this forum.

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    29
    thx
    rags_to_riches

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DIfference between , and ;
    By rocketman03 in forum C++ Programming
    Replies: 6
    Last Post: 10-21-2009, 09:46 AM
  2. Serialization problem
    By noobcpp in forum C++ Programming
    Replies: 17
    Last Post: 07-15-2008, 08:01 PM
  3. Structure pass-by-reference - help?
    By dxfoo in forum C Programming
    Replies: 28
    Last Post: 08-20-2005, 10:16 PM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 06:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21