Simple programming doubt
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: Simple programming doubt

  1. #1
    Join Date
    Jul 2009
    Posts
    8

    Simple programming doubt

    Designation of the Employee according to salary


    #include<iostream.h>
    #include<conio.h>
    void main()
    {
    float sal;
    clrscr();
    cout<<"Enter the salary of employee:";
    cin>>sal;
    if (sal<20000)
    {
    if(sal<=10000)
    cout<<"clerk"<<endl;
    else
    cout<<"Assistant manager:"<<endl;
    }
    else
    cout<<"Manager"<<endl;


    Is this program code right, if it is can you explain why ther is sal<20000 and sal<=10000

    and also how can Assitant manager and Manage can be diffrentiated

  2. #2
    Join Date
    Jul 2009
    Posts
    6

    Re: Simple programming doubt

    #include<iostream>
    #include <stdlib.h>
    using namespace std;

    int main()
    {
    int sal;
    system("cls");

    cout<<"Enter the salary of employee:";

    cin>>sal;

    if (sal<20000)
    {
    if(sal<=10000)
    cout<<"clerk"<<endl;
    else
    cout<<"Assistant manager:"<<endl;
    }
    else
    cout<<"Manager"<<endl;
    return 0;
    }

    I have tested this code on my station and is working ok
    As for your questions it goes like this

    #include<iostream>
    #include <stdlib.h>
    using namespace std;

    int main()
    {
    long int sal;
    system("cls"); // a system call to clear the screen

    cout<<"Enter the salary of employee:"; // print the information on the screen

    cin>>sal; // get the salary



    if (sal<20000) // if the salary is under 20000 execute the first if "if (sal<20000)"
    // if not execute the outer else "cout<<"Manager"<<endl;"
    {
    if(sal<=10000) // if the salary if under or equal to 10000 execute the second if "if(sal<=10000)"
    cout<<"clerk"<<endl; // if not (under 20000 and biger then 10000) execute the inner else " cout<<"Assistant manager:"<<endl;"
    else
    cout<<"Assistant manager:"<<endl;
    }
    else
    cout<<"Manager"<<endl;
    return 0;
    }

  3. #3
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,545

    Re: Simple programming doubt

    Dear lio_cs and jonahmano!
    Please, always use Code tags while posting your code snippets!
    See http://www.codeguru.com/forum/misc.php?do=bbcode#code
    Victor Nijegorodov

  4. #4
    Join Date
    Jul 2009
    Posts
    8

    Re: Simple programming doubt

    you the programming goes this way

    first it will check for salary <20000

    then it will again check for salary<=10000

    so if salary is less than or equal to 10000 then "clerk" will display

    and if salary is in between 10001 and 20000 then "Asst Manager" will display

    else "Manager" will be displayed if salary is greater than 20000


    pls reply


    Thanks for care

  5. #5
    Join Date
    Jul 2009
    Posts
    3

    Re: Simple programming doubt

    Hi friends
    anybody please tell whether we can change the dll of an active x control

  6. #6
    Join Date
    Jul 2009
    Posts
    6

    Re: Simple programming doubt

    Quote Originally Posted by VictorN View Post
    Dear lio_cs and jonahmano!
    Please, always use Code tags while posting your code snippets!
    See http://www.codeguru.com/forum/misc.php?do=bbcode#code
    sorry about that

  7. #7
    Join Date
    Jul 2009
    Posts
    8

    Re: Simple programming doubt

    Lio pls reply


    Is that what i replied mean.


    did I mean right

  8. #8
    Join Date
    Jul 2009
    Posts
    6

    Re: Simple programming doubt

    Quote Originally Posted by jonahmano View Post
    you the programming goes this way

    first it will check for salary <20000

    then it will again check for salary<=10000

    so if salary is less than or equal to 10000 then "clerk" will display

    and if salary is in between 10001 and 20000 then "Asst Manager" will display

    else "Manager" will be displayed if salary is greater than 20000


    pls reply


    Thanks for care
    Yes your right that's what your code is doing

  9. #9
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,206

    Re: Simple programming doubt

    Simpler logic would be (in pseudocode)

    Code:
    if salary > 20000
        output "manager"
    else
    if salary > 10000
        output "assistant manager"
    else
        output "clerk".

  10. #10
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,206

    Re: Simple programming doubt

    Quote Originally Posted by BORN BAD View Post
    Hi friends
    anybody please tell whether we can change the dll of an active x control
    Are you just bumping random threads?

    Start your own thread with a question that makes some kind of sense.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center