-
July 17th, 2009, 05:11 AM
#1
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
-
July 17th, 2009, 05:45 AM
#2
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;
}
-
July 17th, 2009, 05:54 AM
#3
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
-
July 17th, 2009, 05:55 AM
#4
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
-
July 17th, 2009, 06:02 AM
#5
Re: Simple programming doubt
Hi friends
anybody please tell whether we can change the dll of an active x control
-
July 17th, 2009, 06:05 AM
#6
Re: Simple programming doubt
Originally Posted by VictorN
sorry about that
-
July 17th, 2009, 06:14 AM
#7
Re: Simple programming doubt
Lio pls reply
Is that what i replied mean.
did I mean right
-
July 17th, 2009, 06:29 AM
#8
Re: Simple programming doubt
Originally Posted by jonahmano
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
-
July 17th, 2009, 07:21 AM
#9
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".
-
July 17th, 2009, 07:23 AM
#10
Re: Simple programming doubt
Originally Posted by BORN BAD
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|